Previous 199869 Revisions Next

r23731 Sunday 16th June, 2013 at 01:19:07 UTC by smf
Changed "features" to "identify device". Don't set DRDY immediately when executing identify device as a timer is fired that will set it and trigger an interrupt anyway. Diagnostics fail if no identify device response is available. Set correct register contents at reset. Added edge detection to reset. Clear irq as soon as reset is triggered. Don't clear DRDY when resetting. Only call update_irq if something changed. Removed some places that were setting sector count. Added some #defines for masking bit fields. (nw)
[src/emu/machine]idectrl.c idectrl.h idehd.c idehd.h
[src/mame/drivers]chihiro.c cobra.c kinst.c taitotz.c viper.c

trunk/src/mame/drivers/chihiro.c
r23730r23731
27042704   m_num_cylinders=65535;
27052705   m_num_sectors=255;
27062706   m_num_heads=255;
2707   ide_build_features();
2707   ide_build_identify_device();
27082708}
27092709
27102710int ide_baseboard_device::read_sector(UINT32 lba, void *buffer)
trunk/src/mame/drivers/viper.c
r23730r23731
20342034   m_ide->reset();
20352035   mpc8240_epic_reset();
20362036
2037   UINT8 *ide_features = m_ide->ide_get_features(0);
2037   UINT8 *identify_device = m_ide->identify_device_buffer(0);
20382038
20392039   // Viper expects these settings or the BIOS fails
2040   ide_features[51*2+0] = 0;           /* 51: PIO data transfer cycle timing mode */
2041   ide_features[51*2+1] = 2;
2042   ide_features[67*2+0] = 0xf0;        /* 67: minimum PIO transfer cycle time without flow control */
2043   ide_features[67*2+1] = 0x00;
2040   identify_device[51*2+0] = 0;           /* 51: PIO data transfer cycle timing mode */
2041   identify_device[51*2+1] = 2;
2042   identify_device[67*2+0] = 0xf0;        /* 67: minimum PIO transfer cycle time without flow control */
2043   identify_device[67*2+1] = 0x00;
20442044}
20452045
20462046static const voodoo_config voodoo_intf =
trunk/src/mame/drivers/kinst.c
r23730r23731
215215
216216void kinst_state::machine_reset()
217217{
218   UINT8 *features = m_ide->ide_get_features(0);
218   UINT8 *identify_device = m_ide->identify_device_buffer(0);
219219
220220   if (strncmp(machine().system().name, "kinst2", 6) != 0)
221221   {
222222      /* kinst: tweak the model number so we pass the check */
223      features[27*2+0] = 0x54;
224      features[27*2+1] = 0x53;
225      features[28*2+0] = 0x31;
226      features[28*2+1] = 0x39;
227      features[29*2+0] = 0x30;
228      features[29*2+1] = 0x35;
229      features[30*2+0] = 0x47;
230      features[30*2+1] = 0x41;
231      features[31*2+0] = 0x20;
232      features[31*2+1] = 0x20;
223      identify_device[27*2+0] = 0x54;
224      identify_device[27*2+1] = 0x53;
225      identify_device[28*2+0] = 0x31;
226      identify_device[28*2+1] = 0x39;
227      identify_device[29*2+0] = 0x30;
228      identify_device[29*2+1] = 0x35;
229      identify_device[30*2+0] = 0x47;
230      identify_device[30*2+1] = 0x41;
231      identify_device[31*2+0] = 0x20;
232      identify_device[31*2+1] = 0x20;
233233   }
234234   else
235235   {
236236      /* kinst2: tweak the model number so we pass the check */
237      features[10*2+0] = 0x30;
238      features[10*2+1] = 0x30;
239      features[11*2+0] = 0x54;
240      features[11*2+1] = 0x53;
241      features[12*2+0] = 0x31;
242      features[12*2+1] = 0x39;
243      features[13*2+0] = 0x30;
244      features[13*2+1] = 0x35;
245      features[14*2+0] = 0x47;
246      features[14*2+1] = 0x41;
237      identify_device[10*2+0] = 0x30;
238      identify_device[10*2+1] = 0x30;
239      identify_device[11*2+0] = 0x54;
240      identify_device[11*2+1] = 0x53;
241      identify_device[12*2+0] = 0x31;
242      identify_device[12*2+1] = 0x39;
243      identify_device[13*2+0] = 0x30;
244      identify_device[13*2+1] = 0x35;
245      identify_device[14*2+0] = 0x47;
246      identify_device[14*2+1] = 0x41;
247247   }
248248
249249   /* set a safe base location for video */
trunk/src/mame/drivers/taitotz.c
r23730r23731
25302530{
25312531   if (m_hdd_serial_number != NULL)
25322532   {
2533      UINT8 *ide_features = m_ide->ide_get_features(0);
2533      UINT8 *identify_device = m_ide->identify_device_buffer(0);
25342534
25352535      for (int i=0; i < 20; i++)
25362536      {
2537         ide_features[10*2+(i^1)] = m_hdd_serial_number[i];
2537         identify_device[10*2+(i^1)] = m_hdd_serial_number[i];
25382538      }
25392539   }
25402540}
trunk/src/mame/drivers/cobra.c
r23730r23731
31633163{
31643164   m_sub_interrupt = 0xff;
31653165
3166   UINT8 *ide_features = m_ide->ide_get_features(0);
3166   UINT8 *identify_device = m_ide->identify_device_buffer(0);
31673167
31683168   // Cobra expects these settings or the BIOS fails
3169   ide_features[51*2+0] = 0;           /* 51: PIO data transfer cycle timing mode */
3170   ide_features[51*2+1] = 2;
3171   ide_features[67*2+0] = 0xe0;        /* 67: minimum PIO transfer cycle time without flow control */
3172   ide_features[67*2+1] = 0x01;
3169   identify_device[51*2+0] = 0;           /* 51: PIO data transfer cycle timing mode */
3170   identify_device[51*2+1] = 2;
3171   identify_device[67*2+0] = 0xe0;        /* 67: minimum PIO transfer cycle time without flow control */
3172   identify_device[67*2+1] = 0x01;
31733173
31743174   m_renderer->gfx_reset(machine());
31753175
trunk/src/emu/machine/idehd.c
r23730r23731
4545#define IDE_COMMAND_SET_BLOCK_COUNT         0xc6
4646#define IDE_COMMAND_READ_DMA                0xc8
4747#define IDE_COMMAND_WRITE_DMA               0xca
48#define IDE_COMMAND_GET_INFO                0xec
48#define IDE_COMMAND_IDENTIFY_DEVICE         0xec
4949#define IDE_COMMAND_SET_FEATURES            0xef
5050#define IDE_COMMAND_SECURITY_UNLOCK         0xf2
5151#define IDE_COMMAND_UNKNOWN_F9              0xf9
r23730r23731
5757#define IDE_COMMAND_IDLE_IMMEDIATE          0xe1
5858#define IDE_COMMAND_IDLE                    0xe3
5959
60#define IDE_DEVICE_CONTROL_NIEN 0x02
61#define IDE_DEVICE_CONTROL_SRST 0x04
62
6063enum
6164{
6265   TID_NULL,
r23730r23731
97100
98101void ide_mass_storage_device::update_irq()
99102{
100   if (device_selected() && (m_device_control & 2) == 0)
103   if (device_selected() && (m_device_control & IDE_DEVICE_CONTROL_NIEN) == 0)
101104      m_irq_handler(m_irq);
102105   else
103106      m_irq_handler(CLEAR_LINE);
r23730r23731
152155UINT32 ide_mass_storage_device::lba_address()
153156{
154157   /* LBA direct? */
155   if (m_device_head & 0x40)
156      return ((m_device_head & 0xf) << 24) | (m_cylinder_high << 16) | (m_cylinder_low << 8) | m_sector_number;
158   if (m_device_head & IDE_DEVICE_HEAD_L)
159      return ((m_device_head & IDE_DEVICE_HEAD_HS) << 24) | (m_cylinder_high << 16) | (m_cylinder_low << 8) | m_sector_number;
157160
158161   /* standard CHS */
159162   else
160      return (((((m_cylinder_high << 8 ) | m_cylinder_low) * m_num_heads) + (m_device_head & 0xf)) * m_num_sectors) + m_sector_number - 1;
163      return (((((m_cylinder_high << 8 ) | m_cylinder_low) * m_num_heads) + (m_device_head & IDE_DEVICE_HEAD_HS)) * m_num_sectors) + m_sector_number - 1;
161164}
162165
163166
r23730r23731
180183}
181184
182185
183void ide_mass_storage_device::ide_build_features()
186void ide_mass_storage_device::ide_build_identify_device()
184187{
185   memset(m_features, 0, IDE_DISK_SECTOR_SIZE);
188   memset(m_identify_device, 0, IDE_DISK_SECTOR_SIZE);
186189   int total_sectors = m_num_cylinders * m_num_heads * m_num_sectors;
187190
188191   /* basic geometry */
189   m_features[ 0*2+0] = 0x5a;                      /*  0: configuration bits */
190   m_features[ 0*2+1] = 0x04;
191   m_features[ 1*2+0] = m_num_cylinders & 0xff;    /*  1: logical cylinders */
192   m_features[ 1*2+1] = m_num_cylinders >> 8;
193   m_features[ 2*2+0] = 0;                         /*  2: reserved */
194   m_features[ 2*2+1] = 0;
195   m_features[ 3*2+0] = m_num_heads & 0xff;        /*  3: logical heads */
196   m_features[ 3*2+1] = 0;/*num_heads >> 8;*/
197   m_features[ 4*2+0] = 0;                         /*  4: vendor specific (obsolete) */
198   m_features[ 4*2+1] = 0;
199   m_features[ 5*2+0] = 0;                         /*  5: vendor specific (obsolete) */
200   m_features[ 5*2+1] = 0;
201   m_features[ 6*2+0] = m_num_sectors & 0xff;  /*  6: logical sectors per logical track */
202   m_features[ 6*2+1] = 0;/*num_sectors >> 8;*/
203   m_features[ 7*2+0] = 0;                         /*  7: vendor-specific */
204   m_features[ 7*2+1] = 0;
205   m_features[ 8*2+0] = 0;                         /*  8: vendor-specific */
206   m_features[ 8*2+1] = 0;
207   m_features[ 9*2+0] = 0;                         /*  9: vendor-specific */
208   m_features[ 9*2+1] = 0;
209   swap_strncpy(&m_features[10*2+0],               /* 10-19: serial number */
192   m_identify_device[ 0*2+0] = 0x5a;                      /*  0: configuration bits */
193   m_identify_device[ 0*2+1] = 0x04;
194   m_identify_device[ 1*2+0] = m_num_cylinders & 0xff;    /*  1: logical cylinders */
195   m_identify_device[ 1*2+1] = m_num_cylinders >> 8;
196   m_identify_device[ 2*2+0] = 0;                         /*  2: reserved */
197   m_identify_device[ 2*2+1] = 0;
198   m_identify_device[ 3*2+0] = m_num_heads & 0xff;        /*  3: logical heads */
199   m_identify_device[ 3*2+1] = 0;/*num_heads >> 8;*/
200   m_identify_device[ 4*2+0] = 0;                         /*  4: vendor specific (obsolete) */
201   m_identify_device[ 4*2+1] = 0;
202   m_identify_device[ 5*2+0] = 0;                         /*  5: vendor specific (obsolete) */
203   m_identify_device[ 5*2+1] = 0;
204   m_identify_device[ 6*2+0] = m_num_sectors & 0xff;  /*  6: logical sectors per logical track */
205   m_identify_device[ 6*2+1] = 0;/*num_sectors >> 8;*/
206   m_identify_device[ 7*2+0] = 0;                         /*  7: vendor-specific */
207   m_identify_device[ 7*2+1] = 0;
208   m_identify_device[ 8*2+0] = 0;                         /*  8: vendor-specific */
209   m_identify_device[ 8*2+1] = 0;
210   m_identify_device[ 9*2+0] = 0;                         /*  9: vendor-specific */
211   m_identify_device[ 9*2+1] = 0;
212   swap_strncpy(&m_identify_device[10*2+0],               /* 10-19: serial number */
210213         "00000000000000000000", 10);
211   m_features[20*2+0] = 0;                         /* 20: vendor-specific */
212   m_features[20*2+1] = 0;
213   m_features[21*2+0] = 0;                         /* 21: vendor-specific */
214   m_features[21*2+1] = 0;
215   m_features[22*2+0] = 4;                         /* 22: # of vendor-specific bytes on read/write long commands */
216   m_features[22*2+1] = 0;
217   swap_strncpy(&m_features[23*2+0],               /* 23-26: firmware revision */
214   m_identify_device[20*2+0] = 0;                         /* 20: vendor-specific */
215   m_identify_device[20*2+1] = 0;
216   m_identify_device[21*2+0] = 0;                         /* 21: vendor-specific */
217   m_identify_device[21*2+1] = 0;
218   m_identify_device[22*2+0] = 4;                         /* 22: # of vendor-specific bytes on read/write long commands */
219   m_identify_device[22*2+1] = 0;
220   swap_strncpy(&m_identify_device[23*2+0],               /* 23-26: firmware revision */
218221         "1.0", 4);
219   swap_strncpy(&m_features[27*2+0],               /* 27-46: model number */
222   swap_strncpy(&m_identify_device[27*2+0],               /* 27-46: model number */
220223         "MAME Compressed Hard Disk", 20);
221   m_features[47*2+0] = 0x01;                      /* 47: read/write multiple support */
222   m_features[47*2+1] = 0x80;
223   m_features[48*2+0] = 0;                         /* 48: reserved */
224   m_features[48*2+1] = 0;
225   m_features[49*2+0] = 0x03;                      /* 49: capabilities */
226   m_features[49*2+1] = 0x0f;
227   m_features[50*2+0] = 0;                         /* 50: reserved */
228   m_features[50*2+1] = 0;
229   m_features[51*2+0] = 2;                         /* 51: PIO data transfer cycle timing mode */
230   m_features[51*2+1] = 0;
231   m_features[52*2+0] = 2;                         /* 52: single word DMA transfer cycle timing mode */
232   m_features[52*2+1] = 0;
233   m_features[53*2+0] = 3;                         /* 53: field validity */
234   m_features[53*2+1] = 0;
235   m_features[54*2+0] = m_num_cylinders & 0xff;    /* 54: number of current logical cylinders */
236   m_features[54*2+1] = m_num_cylinders >> 8;
237   m_features[55*2+0] = m_num_heads & 0xff;        /* 55: number of current logical heads */
238   m_features[55*2+1] = 0;/*num_heads >> 8;*/
239   m_features[56*2+0] = m_num_sectors & 0xff;  /* 56: number of current logical sectors per track */
240   m_features[56*2+1] = 0;/*num_sectors >> 8;*/
241   m_features[57*2+0] = total_sectors & 0xff;  /* 57-58: current capacity in sectors (ATA-1 through ATA-5; obsoleted in ATA-6) */
242   m_features[57*2+1] = total_sectors >> 8;
243   m_features[58*2+0] = total_sectors >> 16;
244   m_features[58*2+1] = total_sectors >> 24;
245   m_features[59*2+0] = 0;                         /* 59: multiple sector timing */
246   m_features[59*2+1] = 0;
247   m_features[60*2+0] = total_sectors & 0xff;      /* 60-61: total user addressable sectors for LBA mode (ATA-1 through ATA-7) */
248   m_features[60*2+1] = total_sectors >> 8;
249   m_features[61*2+0] = total_sectors >> 16;
250   m_features[61*2+1] = total_sectors >> 24;
251   m_features[62*2+0] = 0x07;                      /* 62: single word dma transfer */
252   m_features[62*2+1] = 0x00;
253   m_features[63*2+0] = 0x07;                      /* 63: multiword DMA transfer */
254   m_features[63*2+1] = 0x04;
255   m_features[64*2+0] = 0x03;                      /* 64: flow control PIO transfer modes supported */
256   m_features[64*2+1] = 0x00;
257   m_features[65*2+0] = 0x78;                      /* 65: minimum multiword DMA transfer cycle time per word */
258   m_features[65*2+1] = 0x00;
259   m_features[66*2+0] = 0x78;                      /* 66: mfr's recommended multiword DMA transfer cycle time */
260   m_features[66*2+1] = 0x00;
261   m_features[67*2+0] = 0x4d;                      /* 67: minimum PIO transfer cycle time without flow control */
262   m_features[67*2+1] = 0x01;
263   m_features[68*2+0] = 0x78;                      /* 68: minimum PIO transfer cycle time with IORDY */
264   m_features[68*2+1] = 0x00;
265   m_features[69*2+0] = 0x00;                      /* 69-70: reserved */
266   m_features[69*2+1] = 0x00;
267   m_features[71*2+0] = 0x00;                      /* 71: reserved for IDENTIFY PACKET command */
268   m_features[71*2+1] = 0x00;
269   m_features[72*2+0] = 0x00;                      /* 72: reserved for IDENTIFY PACKET command */
270   m_features[72*2+1] = 0x00;
271   m_features[73*2+0] = 0x00;                      /* 73: reserved for IDENTIFY PACKET command */
272   m_features[73*2+1] = 0x00;
273   m_features[74*2+0] = 0x00;                      /* 74: reserved for IDENTIFY PACKET command */
274   m_features[74*2+1] = 0x00;
275   m_features[75*2+0] = 0x00;                      /* 75: queue depth */
276   m_features[75*2+1] = 0x00;
277   m_features[76*2+0] = 0x00;                      /* 76-79: reserved */
278   m_features[76*2+1] = 0x00;
279   m_features[80*2+0] = 0x00;                      /* 80: major version number */
280   m_features[80*2+1] = 0x00;
281   m_features[81*2+0] = 0x00;                      /* 81: minor version number */
282   m_features[81*2+1] = 0x00;
283   m_features[82*2+0] = 0x00;                      /* 82: command set supported */
284   m_features[82*2+1] = 0x00;
285   m_features[83*2+0] = 0x00;                      /* 83: command sets supported */
286   m_features[83*2+1] = 0x00;
287   m_features[84*2+0] = 0x00;                      /* 84: command set/feature supported extension */
288   m_features[84*2+1] = 0x00;
289   m_features[85*2+0] = 0x00;                      /* 85: command set/feature enabled */
290   m_features[85*2+1] = 0x00;
291   m_features[86*2+0] = 0x00;                      /* 86: command set/feature enabled */
292   m_features[86*2+1] = 0x00;
293   m_features[87*2+0] = 0x00;                      /* 87: command set/feature default */
294   m_features[87*2+1] = 0x00;
295   m_features[88*2+0] = 0x00;                      /* 88: additional DMA modes */
296   m_features[88*2+1] = 0x00;
297   m_features[89*2+0] = 0x00;                      /* 89: time required for security erase unit completion */
298   m_features[89*2+1] = 0x00;
299   m_features[90*2+0] = 0x00;                      /* 90: time required for enhanced security erase unit completion */
300   m_features[90*2+1] = 0x00;
301   m_features[91*2+0] = 0x00;                      /* 91: current advanced power management value */
302   m_features[91*2+1] = 0x00;
303   m_features[92*2+0] = 0x00;                      /* 92: master password revision code */
304   m_features[92*2+1] = 0x00;
305   m_features[93*2+0] = 0x00;                      /* 93: hardware reset result */
306   m_features[93*2+1] = 0x00;
307   m_features[94*2+0] = 0x00;                      /* 94: acoustic management values */
308   m_features[94*2+1] = 0x00;
309   m_features[95*2+0] = 0x00;                      /* 95-99: reserved */
310   m_features[95*2+1] = 0x00;
311   m_features[100*2+0] = total_sectors & 0xff;     /* 100-103: maximum 48-bit LBA */
312   m_features[100*2+1] = total_sectors >> 8;
313   m_features[101*2+0] = total_sectors >> 16;
314   m_features[101*2+1] = total_sectors >> 24;
315   m_features[102*2+0] = 0x00;
316   m_features[102*2+1] = 0x00;
317   m_features[103*2+0] = 0x00;
318   m_features[103*2+1] = 0x00;
319   m_features[104*2+0] = 0x00;                     /* 104-126: reserved */
320   m_features[104*2+1] = 0x00;
321   m_features[127*2+0] = 0x00;                     /* 127: removable media status notification */
322   m_features[127*2+1] = 0x00;
323   m_features[128*2+0] = 0x00;                     /* 128: security status */
324   m_features[128*2+1] = 0x00;
325   m_features[129*2+0] = 0x00;                     /* 129-159: vendor specific */
326   m_features[129*2+1] = 0x00;
327   m_features[160*2+0] = 0x00;                     /* 160: CFA power mode 1 */
328   m_features[160*2+1] = 0x00;
329   m_features[161*2+0] = 0x00;                     /* 161-175: reserved for CompactFlash */
330   m_features[161*2+1] = 0x00;
331   m_features[176*2+0] = 0x00;                     /* 176-205: current media serial number */
332   m_features[176*2+1] = 0x00;
333   m_features[206*2+0] = 0x00;                     /* 206-254: reserved */
334   m_features[206*2+1] = 0x00;
335   m_features[255*2+0] = 0x00;                     /* 255: integrity word */
336   m_features[255*2+1] = 0x00;
224   m_identify_device[47*2+0] = 0x01;                      /* 47: read/write multiple support */
225   m_identify_device[47*2+1] = 0x80;
226   m_identify_device[48*2+0] = 0;                         /* 48: reserved */
227   m_identify_device[48*2+1] = 0;
228   m_identify_device[49*2+0] = 0x03;                      /* 49: capabilities */
229   m_identify_device[49*2+1] = 0x0f;
230   m_identify_device[50*2+0] = 0;                         /* 50: reserved */
231   m_identify_device[50*2+1] = 0;
232   m_identify_device[51*2+0] = 2;                         /* 51: PIO data transfer cycle timing mode */
233   m_identify_device[51*2+1] = 0;
234   m_identify_device[52*2+0] = 2;                         /* 52: single word DMA transfer cycle timing mode */
235   m_identify_device[52*2+1] = 0;
236   m_identify_device[53*2+0] = 3;                         /* 53: field validity */
237   m_identify_device[53*2+1] = 0;
238   m_identify_device[54*2+0] = m_num_cylinders & 0xff;    /* 54: number of current logical cylinders */
239   m_identify_device[54*2+1] = m_num_cylinders >> 8;
240   m_identify_device[55*2+0] = m_num_heads & 0xff;        /* 55: number of current logical heads */
241   m_identify_device[55*2+1] = 0;/*num_heads >> 8;*/
242   m_identify_device[56*2+0] = m_num_sectors & 0xff;  /* 56: number of current logical sectors per track */
243   m_identify_device[56*2+1] = 0;/*num_sectors >> 8;*/
244   m_identify_device[57*2+0] = total_sectors & 0xff;  /* 57-58: current capacity in sectors (ATA-1 through ATA-5; obsoleted in ATA-6) */
245   m_identify_device[57*2+1] = total_sectors >> 8;
246   m_identify_device[58*2+0] = total_sectors >> 16;
247   m_identify_device[58*2+1] = total_sectors >> 24;
248   m_identify_device[59*2+0] = 0;                         /* 59: multiple sector timing */
249   m_identify_device[59*2+1] = 0;
250   m_identify_device[60*2+0] = total_sectors & 0xff;      /* 60-61: total user addressable sectors for LBA mode (ATA-1 through ATA-7) */
251   m_identify_device[60*2+1] = total_sectors >> 8;
252   m_identify_device[61*2+0] = total_sectors >> 16;
253   m_identify_device[61*2+1] = total_sectors >> 24;
254   m_identify_device[62*2+0] = 0x07;                      /* 62: single word dma transfer */
255   m_identify_device[62*2+1] = 0x00;
256   m_identify_device[63*2+0] = 0x07;                      /* 63: multiword DMA transfer */
257   m_identify_device[63*2+1] = 0x04;
258   m_identify_device[64*2+0] = 0x03;                      /* 64: flow control PIO transfer modes supported */
259   m_identify_device[64*2+1] = 0x00;
260   m_identify_device[65*2+0] = 0x78;                      /* 65: minimum multiword DMA transfer cycle time per word */
261   m_identify_device[65*2+1] = 0x00;
262   m_identify_device[66*2+0] = 0x78;                      /* 66: mfr's recommended multiword DMA transfer cycle time */
263   m_identify_device[66*2+1] = 0x00;
264   m_identify_device[67*2+0] = 0x4d;                      /* 67: minimum PIO transfer cycle time without flow control */
265   m_identify_device[67*2+1] = 0x01;
266   m_identify_device[68*2+0] = 0x78;                      /* 68: minimum PIO transfer cycle time with IORDY */
267   m_identify_device[68*2+1] = 0x00;
268   m_identify_device[69*2+0] = 0x00;                      /* 69-70: reserved */
269   m_identify_device[69*2+1] = 0x00;
270   m_identify_device[71*2+0] = 0x00;                      /* 71: reserved for IDENTIFY PACKET command */
271   m_identify_device[71*2+1] = 0x00;
272   m_identify_device[72*2+0] = 0x00;                      /* 72: reserved for IDENTIFY PACKET command */
273   m_identify_device[72*2+1] = 0x00;
274   m_identify_device[73*2+0] = 0x00;                      /* 73: reserved for IDENTIFY PACKET command */
275   m_identify_device[73*2+1] = 0x00;
276   m_identify_device[74*2+0] = 0x00;                      /* 74: reserved for IDENTIFY PACKET command */
277   m_identify_device[74*2+1] = 0x00;
278   m_identify_device[75*2+0] = 0x00;                      /* 75: queue depth */
279   m_identify_device[75*2+1] = 0x00;
280   m_identify_device[76*2+0] = 0x00;                      /* 76-79: reserved */
281   m_identify_device[76*2+1] = 0x00;
282   m_identify_device[80*2+0] = 0x00;                      /* 80: major version number */
283   m_identify_device[80*2+1] = 0x00;
284   m_identify_device[81*2+0] = 0x00;                      /* 81: minor version number */
285   m_identify_device[81*2+1] = 0x00;
286   m_identify_device[82*2+0] = 0x00;                      /* 82: command set supported */
287   m_identify_device[82*2+1] = 0x00;
288   m_identify_device[83*2+0] = 0x00;                      /* 83: command sets supported */
289   m_identify_device[83*2+1] = 0x00;
290   m_identify_device[84*2+0] = 0x00;                      /* 84: command set/feature supported extension */
291   m_identify_device[84*2+1] = 0x00;
292   m_identify_device[85*2+0] = 0x00;                      /* 85: command set/feature enabled */
293   m_identify_device[85*2+1] = 0x00;
294   m_identify_device[86*2+0] = 0x00;                      /* 86: command set/feature enabled */
295   m_identify_device[86*2+1] = 0x00;
296   m_identify_device[87*2+0] = 0x00;                      /* 87: command set/feature default */
297   m_identify_device[87*2+1] = 0x00;
298   m_identify_device[88*2+0] = 0x00;                      /* 88: additional DMA modes */
299   m_identify_device[88*2+1] = 0x00;
300   m_identify_device[89*2+0] = 0x00;                      /* 89: time required for security erase unit completion */
301   m_identify_device[89*2+1] = 0x00;
302   m_identify_device[90*2+0] = 0x00;                      /* 90: time required for enhanced security erase unit completion */
303   m_identify_device[90*2+1] = 0x00;
304   m_identify_device[91*2+0] = 0x00;                      /* 91: current advanced power management value */
305   m_identify_device[91*2+1] = 0x00;
306   m_identify_device[92*2+0] = 0x00;                      /* 92: master password revision code */
307   m_identify_device[92*2+1] = 0x00;
308   m_identify_device[93*2+0] = 0x00;                      /* 93: hardware reset result */
309   m_identify_device[93*2+1] = 0x00;
310   m_identify_device[94*2+0] = 0x00;                      /* 94: acoustic management values */
311   m_identify_device[94*2+1] = 0x00;
312   m_identify_device[95*2+0] = 0x00;                      /* 95-99: reserved */
313   m_identify_device[95*2+1] = 0x00;
314   m_identify_device[100*2+0] = total_sectors & 0xff;     /* 100-103: maximum 48-bit LBA */
315   m_identify_device[100*2+1] = total_sectors >> 8;
316   m_identify_device[101*2+0] = total_sectors >> 16;
317   m_identify_device[101*2+1] = total_sectors >> 24;
318   m_identify_device[102*2+0] = 0x00;
319   m_identify_device[102*2+1] = 0x00;
320   m_identify_device[103*2+0] = 0x00;
321   m_identify_device[103*2+1] = 0x00;
322   m_identify_device[104*2+0] = 0x00;                     /* 104-126: reserved */
323   m_identify_device[104*2+1] = 0x00;
324   m_identify_device[127*2+0] = 0x00;                     /* 127: removable media status notification */
325   m_identify_device[127*2+1] = 0x00;
326   m_identify_device[128*2+0] = 0x00;                     /* 128: security status */
327   m_identify_device[128*2+1] = 0x00;
328   m_identify_device[129*2+0] = 0x00;                     /* 129-159: vendor specific */
329   m_identify_device[129*2+1] = 0x00;
330   m_identify_device[160*2+0] = 0x00;                     /* 160: CFA power mode 1 */
331   m_identify_device[160*2+1] = 0x00;
332   m_identify_device[161*2+0] = 0x00;                     /* 161-175: reserved for CompactFlash */
333   m_identify_device[161*2+1] = 0x00;
334   m_identify_device[176*2+0] = 0x00;                     /* 176-205: current media serial number */
335   m_identify_device[176*2+1] = 0x00;
336   m_identify_device[206*2+0] = 0x00;                     /* 206-254: reserved */
337   m_identify_device[206*2+1] = 0x00;
338   m_identify_device[255*2+0] = 0x00;                     /* 255: integrity word */
339   m_identify_device[255*2+1] = 0x00;
337340}
338341
339342//-------------------------------------------------
r23730r23731
358361   save_item(NAME(m_command));
359362   save_item(NAME(m_device_control));
360363
361   save_item(NAME(m_has_features));
362   save_item(NAME(m_features));
364   save_item(NAME(m_can_identify_device));
365   save_item(NAME(m_identify_device));
363366   save_item(NAME(m_cur_lba));
364367   save_item(NAME(m_irq));
365368   save_item(NAME(m_dmarq));
r23730r23731
386389      m_status |= IDE_STATUS_DRDY;
387390   }
388391
392   if (m_can_identify_device)
393      m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
394   else
395      m_error = IDE_ERROR_DIAGNOSTIC_FAILED;
396
397   m_sector_count = 1;
398   m_sector_number = 1;
399   m_cylinder_low = 0;
400   m_cylinder_high = 0;
401   m_device_head = 0;
402
389403   /* reset the drive state */
390404   set_irq(CLEAR_LINE);
391405   set_dmarq(CLEAR_LINE);
r23730r23731
444458void ide_mass_storage_device::next_sector()
445459{
446460   /* LBA direct? */
447   if (m_device_head & 0x40)
461   if (m_device_head & IDE_DEVICE_HEAD_L)
448462   {
449463      m_sector_number++;
450464      if (m_sector_number == 0)
r23730r23731
454468         {
455469            m_cylinder_high++;
456470            if( m_cylinder_high == 0)
457               m_device_head = (m_device_head & ~0xf) | ((m_device_head + 1) & 0xf);
471               m_device_head = (m_device_head & ~IDE_DEVICE_HEAD_HS) | ((m_device_head + 1) & IDE_DEVICE_HEAD_HS);
458472         }
459473      }
460474   }
r23730r23731
468482      {
469483         /* heads are 0 based */
470484         m_sector_number = 1;
471         m_device_head = (m_device_head & ~0xf) | ((m_device_head + 1) & 0xf);
472         if ((m_device_head & 0xf) >= m_num_heads)
485         m_device_head = (m_device_head & ~IDE_DEVICE_HEAD_HS) | ((m_device_head + 1) & IDE_DEVICE_HEAD_HS);
486         if ((m_device_head & IDE_DEVICE_HEAD_HS) >= m_num_heads)
473487         {
474            m_device_head &= ~0xf;
488            m_device_head &= ~IDE_DEVICE_HEAD_HS;
475489            m_cylinder_low++;
476490            if (m_cylinder_low == 0)
477491               m_cylinder_high++;
r23730r23731
517531   if (m_master_password_enable || m_user_password_enable)
518532   {
519533      security_error();
520      m_sector_count = 0;
521534      return;
522535   }
523536
r23730r23731
772785   case IDE_COMMAND_READ_SECTORS:
773786   case IDE_COMMAND_READ_SECTORS_NORETRY:
774787      LOGPRINT(("IDE Read multiple: C=%d H=%d S=%d LBA=%d count=%d\n",
775         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & 0xf, m_sector_number, lba_address(), m_sector_count));
788         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
776789
777790      m_sectors_until_int = 1;
778791
r23730r23731
782795
783796   case IDE_COMMAND_READ_MULTIPLE:
784797      LOGPRINT(("IDE Read multiple block: C=%d H=%d S=%d LBA=%d count=%d\n",
785         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & 0xf, m_sector_number, lba_address(), m_sector_count));
798         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
786799
787800      m_sectors_until_int = 1;
788801
r23730r23731
793806   case IDE_COMMAND_VERIFY_SECTORS:
794807   case IDE_COMMAND_VERIFY_SECTORS_NORETRY:
795808      LOGPRINT(("IDE Read verify multiple with/without retries: C=%d H=%d S=%d LBA=%d count=%d\n",
796         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & 0xf, m_sector_number, lba_address(), m_sector_count));
809         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
797810
798811      /* reset the buffer */
799812      m_sectors_until_int = m_sector_count;
r23730r23731
804817
805818   case IDE_COMMAND_READ_DMA:
806819      LOGPRINT(("IDE Read multiple DMA: C=%d H=%d S=%d LBA=%d count=%d\n",
807         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & 0xf, m_sector_number, lba_address(), m_sector_count));
820         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
808821
809822      /* reset the buffer */
810823      m_sectors_until_int = m_sector_count;
r23730r23731
816829   case IDE_COMMAND_WRITE_SECTORS:
817830   case IDE_COMMAND_WRITE_SECTORS_NORETRY:
818831      LOGPRINT(("IDE Write multiple: C=%d H=%d S=%d LBA=%d count=%d\n",
819         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & 0xf, m_sector_number, lba_address(), m_sector_count));
832         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
820833
821834      /* reset the buffer */
822835      m_sectors_until_int = 1;
r23730r23731
827840
828841   case IDE_COMMAND_WRITE_MULTIPLE:
829842      LOGPRINT(("IDE Write multiple block: C=%d H=%d S=%d LBA=%d count=%d\n",
830         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & 0xf, m_sector_number, lba_address(), m_sector_count));
843         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
831844
832845      /* reset the buffer */
833846      m_sectors_until_int = 1;
r23730r23731
838851
839852   case IDE_COMMAND_WRITE_DMA:
840853      LOGPRINT(("IDE Write multiple DMA: C=%d H=%d S=%d LBA=%d count=%d\n",
841         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & 0xf, m_sector_number, lba_address(), m_sector_count));
854         (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
842855
843856      /* reset the buffer */
844857      m_sectors_until_int = m_sector_count;
r23730r23731
859872      set_irq(ASSERT_LINE);
860873      return true;
861874
862   case IDE_COMMAND_GET_INFO:
863      LOGPRINT(("IDE Read features\n"));
875   case IDE_COMMAND_IDENTIFY_DEVICE:
876      LOGPRINT(("IDE Identify device\n"));
864877
865      if (m_has_features)
878      if (m_can_identify_device)
866879      {
867         m_sector_count = 1;
880         memcpy(m_buffer, m_identify_device, sizeof(m_buffer));
868881
869         /* build the features page */
870         memcpy(m_buffer, m_features, sizeof(m_buffer));
871
872         /* indicate everything is ready */
873         m_status |= IDE_STATUS_DRQ;
874
875882         /* signal an interrupt */
876883         signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 1);
877884      }
r23730r23731
880887         m_status |= IDE_STATUS_ERR;
881888         m_error = IDE_ERROR_NONE;
882889         m_status &= ~IDE_STATUS_DRDY;
883         set_irq(ASSERT_LINE);
890         signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0);
884891      }
885892      return true;
886893
887894   case IDE_COMMAND_DIAGNOSTIC:
888      m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
895      if (m_can_identify_device)
896         m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
897      else
898         m_error = IDE_ERROR_DIAGNOSTIC_FAILED;
889899
890900      /* signal an interrupt */
891901      signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0);
r23730r23731
897907      return true;
898908
899909   case IDE_COMMAND_IDLE:
900      /* for timeout disabled value is 0 */
901      m_sector_count = 0;
902910      /* signal an interrupt */
903911      set_irq(ASSERT_LINE);
904912      return true;
905913
906914   case IDE_COMMAND_SET_CONFIG:
907      LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", (m_device_head & 0xf) + 1, m_sector_count));
908      set_geometry(m_sector_count,(m_device_head & 0xf) + 1);
915      LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", (m_device_head & IDE_DEVICE_HEAD_HS) + 1, m_sector_count));
916      set_geometry(m_sector_count,(m_device_head & IDE_DEVICE_HEAD_HS) + 1);
909917
910918      /* signal an interrupt */
911919      signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0);
r23730r23731
936944      return true;
937945
938946   case IDE_COMMAND_SEEK:
939      /*
940         cur_cylinder, cur_sector and cur_head
941         are all already set in this case so no need
942         so that implements actual seek
943      */
944
945      /* for timeout disabled value is 0 */
946      m_sector_count = 0;
947
948947      /* signal an interrupt */
949948      set_irq(ASSERT_LINE);
950949      return true;
r23730r23731
12311230   }
12321231   else
12331232   {
1233      UINT8 old;
1234
12341235      switch (offset)
12351236      {
12361237         /* write data */
r23730r23731
12841285
12851286         /* current head */
12861287         case IDE_CS0_DEVICE_HEAD_RW:
1288            old = m_device_head;
12871289            m_device_head = data;
12881290
1289            update_irq();
1291            if ((m_device_head ^ old) & IDE_DEVICE_HEAD_DRV)
1292               update_irq();
12901293            break;
12911294
12921295         /* command */
r23730r23731
13291332   }
13301333   else
13311334   {
1335      UINT8 old;
1336
13321337      switch (offset)
13331338      {
13341339         /* adapter control */
13351340         case IDE_CS1_DEVICE_CONTROL_W:
1341            old = m_device_control;
13361342            m_device_control = data;
13371343
1338            update_irq();
1344            if ((m_device_control ^ old) & IDE_DEVICE_CONTROL_NIEN)
1345               update_irq();
13391346
1340            if (data & 0x04)
1347            if ((m_device_control ^ old) & IDE_DEVICE_CONTROL_SRST)
13411348            {
1342               // SRST
1343               m_status |= IDE_STATUS_BSY;
1344               m_status &= ~IDE_STATUS_DRDY;
1345               m_reset_timer->adjust(attotime::from_msec(5));
1349               if (m_device_control & IDE_DEVICE_CONTROL_SRST)
1350               {
1351                  m_status |= IDE_STATUS_BSY;
1352                  set_irq(CLEAR_LINE);
1353                  m_reset_timer->adjust(attotime::from_msec(5));
1354               }
13461355            }
13471356            break;
13481357      }
r23730r23731
14031412      }
14041413      // build the features page
14051414      UINT32 metalength;
1406      if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, m_features, IDE_DISK_SECTOR_SIZE, metalength) != CHDERR_NONE)
1407         ide_build_features();
1415      if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, m_identify_device, IDE_DISK_SECTOR_SIZE, metalength) != CHDERR_NONE)
1416         ide_build_identify_device();
14081417
1409      m_has_features = 1;
1418      m_can_identify_device = 1;
14101419   }
14111420}
14121421
trunk/src/emu/machine/idehd.h
r23730r23731
3838#define IDE_ERROR_DIAGNOSTIC_PASSED 0x01
3939#define IDE_ERROR_DIAGNOSTIC_DEVICE1_FAILED 0x81
4040
41#define IDE_DEVICE_HEAD_HS   0x0f
42#define IDE_DEVICE_HEAD_DRV  0x10
43#define IDE_DEVICE_HEAD_L    0x40
44
4145// ======================> ide_device_interface
4246
4347class ide_device_interface
r23730r23731
5862   virtual DECLARE_WRITE_LINE_MEMBER(write_dasp) = 0;
5963
6064   virtual bool is_ready() { return true; }
61   virtual UINT8 *get_features() = 0;
65   virtual UINT8 *identify_device_buffer() = 0;
6266
6367   UINT8           m_master_password_enable;
6468   UINT8           m_user_password_enable;
r23730r23731
8791   virtual DECLARE_WRITE_LINE_MEMBER(write_dasp);
8892   virtual DECLARE_WRITE_LINE_MEMBER(write_dmack);
8993
90   virtual UINT8 *get_features() { return m_features; }
94   virtual UINT8 *identify_device_buffer() { return m_identify_device; }
9195   
9296protected:
9397   virtual void device_start();
r23730r23731
98102   virtual int write_sector(UINT32 lba, const void *buffer) = 0;
99103   virtual void read_key(UINT8 key[]) = 0;
100104
101   bool device_selected() { return m_csel == (m_device_head & 0x10) >> 4; }
105   bool device_selected() { return m_csel == (m_device_head & IDE_DEVICE_HEAD_DRV) >> 4; }
102106   bool single_device() { return m_csel == 0 && m_dasp == 0; }
103107
104108   void set_irq(int state);
105109   void set_dmarq(int state);
106   void ide_build_features();
110   void ide_build_identify_device();
107111
108112   virtual bool process_command();
109113   virtual void process_buffer();
r23730r23731
121125   UINT8           m_command;
122126   UINT8           m_device_control;
123127
124   int m_has_features;
125   UINT8           m_features[IDE_DISK_SECTOR_SIZE];
128   int m_can_identify_device;
129   UINT8           m_identify_device[IDE_DISK_SECTOR_SIZE];
126130   UINT16          m_num_cylinders;
127131   UINT8           m_num_sectors;
128132   UINT8           m_num_heads;
trunk/src/emu/machine/idectrl.c
r23730r23731
8080    INITIALIZATION AND RESET
8181***************************************************************************/
8282
83UINT8 *ide_controller_device::ide_get_features(int _drive)
83UINT8 *ide_controller_device::identify_device_buffer(int _drive)
8484{
85   return m_slot[_drive]->dev()->get_features();
85   return m_slot[_drive]->dev()->identify_device_buffer();
8686}
8787
8888void ide_controller_device::ide_set_master_password(int _drive, const UINT8 *password)
trunk/src/emu/machine/idectrl.h
r23730r23731
8787   template<class _Object> static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast<ide_controller_device &>(device).m_irq_handler.set_callback(object); }
8888   template<class _Object> static devcb2_base &set_dmarq_handler(device_t &device, _Object object) { return downcast<ide_controller_device &>(device).m_dmarq_handler.set_callback(object); }
8989
90   UINT8 *ide_get_features(int drive);
90   UINT8 *identify_device_buffer(int drive);
9191   void ide_set_master_password(int drive, const UINT8 *password);
9292   void ide_set_user_password(int drive, const UINT8 *password);
9393

Previous 199869 Revisions Next


© 1997-2024 The MAME Team