Previous 15994 Revisions Next

r3890 Friday 19th December, 2008 at 21:05:17 UTC by Wilbert Pol
Removed Machine usage from machine/pc_hdc.
[src/mess/machine]at.c pc.c pc_hdc.c pc_hdc.h

src/mess/machine/at.c
r3889r3890
269269
270270
271271static DMA8237_CHANNEL_READ( at_dma8237_hdc_dack_r ) {
272   return pc_hdc_dack_r();
272   return pc_hdc_dack_r( device->machine );
273273}
274274
275275
r3889r3890
279279
280280
281281static DMA8237_CHANNEL_WRITE( at_dma8237_hdc_dack_w ) {
282   pc_hdc_dack_w( data );
282   pc_hdc_dack_w( device->machine, data );
283283}
284284
285285
src/mess/machine/pc_hdc.c
r3889r3890
3434#include "machine/8237dma.h"
3535#include "devices/harddriv.h"
3636#include "memconv.h"
37#include "deprecat.h"
3837
3938
4039#define LOG_HDC_STATUS      0
r3889r3890
209208}
210209
211210
212static hard_disk_file *pc_hdc_file(int id)
211static hard_disk_file *pc_hdc_file(running_machine *machine, int id)
213212{
214213   const device_config *img = NULL;
215214
216215   switch( id )
217216   {
218217   case 0:
219      img = device_list_find_by_tag( Machine->config->devicelist, HARDDISK, "harddisk1" );
218      img = device_list_find_by_tag( machine->config->devicelist, HARDDISK, "harddisk1" );
220219      break;
221220   case 1:
222      img = device_list_find_by_tag( Machine->config->devicelist, HARDDISK, "harddisk2" );
221      img = device_list_find_by_tag( machine->config->devicelist, HARDDISK, "harddisk2" );
223222      break;
224223   case 2:
225      img = device_list_find_by_tag( Machine->config->devicelist, HARDDISK, "harddisk3" );
224      img = device_list_find_by_tag( machine->config->devicelist, HARDDISK, "harddisk3" );
226225      break;
227226   case 3:
228      img = device_list_find_by_tag( Machine->config->devicelist, HARDDISK, "harddisk4" );
227      img = device_list_find_by_tag( machine->config->devicelist, HARDDISK, "harddisk4" );
229228      break;
230229   }
231230
r3889r3890
287286
288287
289288
290static int get_lbasector(void)
289static int get_lbasector(running_machine *machine)
291290{
292291   hard_disk_info *info;
293292   hard_disk_file *file;
294293   int lbasector;
295294
296   file = pc_hdc_file(idx);
295   file = pc_hdc_file(machine, idx);
297296   info = hard_disk_get_info(file);
298297
299298   lbasector = cylinder[idx];
r3889r3890
322321static int hdcdma_write;
323322static int hdcdma_size;
324323
325int pc_hdc_dack_r(void)
324int pc_hdc_dack_r(running_machine *machine)
326325{
327326   UINT8 result;
328327   hard_disk_info *info;
329328   hard_disk_file *file;
330329
331   file = pc_hdc_file(idx);
330   file = pc_hdc_file(machine, idx);
332331   if (!file)
333332      return 0;
334333   info = hard_disk_get_info(file);
335334
336335   if (hdcdma_read == 0)
337336   {
338      hard_disk_read(file, get_lbasector(), hdcdma_data);
337      hard_disk_read(file, get_lbasector(machine), hdcdma_data);
339338      hdcdma_read = 512;
340339      hdcdma_size -= 512;
341340      hdcdma_src = hdcdma_data;
r3889r3890
363362
364363
365364
366void pc_hdc_dack_w(int data)
365void pc_hdc_dack_w(running_machine *machine, int data)
367366{
368367   hard_disk_info *info;
369368   hard_disk_file *file;
370369
371   file = pc_hdc_file(idx);
370   file = pc_hdc_file(machine, idx);
372371   if (!file)
373372      return;
374373   info = hard_disk_get_info(file);
r3889r3890
377376
378377   if( --hdcdma_write == 0 )
379378   {
380      hard_disk_write(file, get_lbasector(), hdcdma_data);
379      hard_disk_write(file, get_lbasector(machine), hdcdma_data);
381380      hdcdma_write = 512;
382381      hdcdma_size -= 512;
383382
r3889r3890
397396
398397
399398
400static void execute_read(void)
399static void execute_read(running_machine *machine)
401400{
402   hard_disk_file *disk = pc_hdc_file(idx);
401   hard_disk_file *disk = pc_hdc_file(machine, idx);
403402   UINT8 data[512], *src = data;
404403   int size = sector_cnt[idx] * 512;
405404   int read_ = 0;
406405
407   disk = pc_hdc_file(idx);
406   disk = pc_hdc_file(machine, idx);
408407   if (!disk)
409408      return;
410409
r3889r3890
417416   {
418417      do
419418      {
420         buffer[data_cnt++] = pc_hdc_dack_r();
419         buffer[data_cnt++] = pc_hdc_dack_r( machine );
421420      } while (hdcdma_read || hdcdma_size);
422421   }
423422   else
r3889r3890
428427
429428
430429
431static void execute_write(void)
430static void execute_write(running_machine *machine)
432431{
433   hard_disk_file *disk = pc_hdc_file(idx);
432   hard_disk_file *disk = pc_hdc_file(machine, idx);
434433   UINT8 data[512], *dst = data;
435434   int size = sector_cnt[idx] * 512;
436435   int write_ = 512;
437436
438   disk = pc_hdc_file(idx);
437   disk = pc_hdc_file(machine, idx);
439438   if (!disk)
440439      return;
441440
r3889r3890
448447   {
449448      do
450449      {
451         pc_hdc_dack_w(buffer[data_cnt++]);
450         pc_hdc_dack_w(machine, buffer[data_cnt++]);
452451      }
453452      while (hdcdma_write || hdcdma_size);
454453   }
r3889r3890
481480   error[n] = 0x80;   /* a potential error has C/H/S/N info */
482481}
483482
484static int test_ready(int n)
483static int test_ready(running_machine *machine, int n)
485484{
486   if( !pc_hdc_file(idx) )
485   if( !pc_hdc_file(machine, idx) )
487486   {
488487      csb[n] |= CSB_ERROR;
489488      error[n] |= 0x04;   /* drive not ready */
r3889r3890
519518   {
520519      case CMD_TESTREADY:
521520         set_error_info = 0;
522         test_ready(n);
521         test_ready(machine, n);
523522            break;
524523      case CMD_SENSE:
525524         /* Perform error code translation. This may need to be expanded in the future. */
r3889r3890
540539      case CMD_SEEK:
541540      case CMD_DRIVEDIAG:
542541         get_chsn(n);
543         test_ready(n);
542         test_ready(machine, n);
544543            break;
545544
546545      case CMD_READ:
r3889r3890
553552               (unsigned) cpu_get_reg(machine->cpu[0], REG_PC), idx, drv, cylinder[idx], head[idx], sector[idx], sector_cnt[idx], control[idx]);
554553         }
555554
556         if (test_ready(n))
557            execute_read();
555         if (test_ready(machine, n))
556            execute_read(machine);
558557         set_error_info = 0;
559558         break;
560559
r3889r3890
568567               (unsigned) cpu_get_reg(machine->cpu[0], REG_PC), idx, drv, cylinder[idx], head[idx], sector[idx], sector_cnt[idx], control[idx]);
569568         }
570569
571         if (test_ready(n))
572            execute_write();
570         if (test_ready(machine, n))
571            execute_write(machine);
573572         break;
574573
575574      case CMD_SETPARAM:
r3889r3890
616615 *   cccccccc write precomp l
617616 *   eeeeeeee ecc
618617 */
619static void pc_hdc_data_w(int n, int data)
618static void pc_hdc_data_w(running_machine *machine, int n, int data)
620619{
621620   if( data_cnt == 0 )
622621   {
r3889r3890
674673      if (--data_cnt == 0)
675674      {
676675         if (LOG_HDC_STATUS)
677            logerror("pc_hdc_data_w(): Launching command; pc=0x%08x\n", (unsigned) cpu_get_reg(Machine->cpu[0], REG_PC));
676            logerror("pc_hdc_data_w(): Launching command; pc=0x%08x\n", (unsigned) cpu_get_reg(machine->cpu[0], REG_PC));
678677
679678            status[n] &= ~STA_COMMAND;
680679         status[n] &= ~STA_REQUEST;
r3889r3890
711710
712711
713712
714static void pc_hdc_control_w(int n, int data)
713static void pc_hdc_control_w(running_machine *machine, int n, int data)
715714{
716715   int irq = irq = (dip[n] & 0x40) ? 5 : 2;
717716
718717   if (LOG_HDC_STATUS)
719      logerror("pc_hdc_control_w(): Control write pc=0x%08x data=%d\n", (unsigned) cpu_get_reg(Machine->cpu[0], REG_PC), data);
718      logerror("pc_hdc_control_w(): Control write pc=0x%08x data=%d\n", (unsigned) cpu_get_reg(machine->cpu[0], REG_PC), data);
720719
721720   hdc_control = data;
722721
r3889r3890
785784 *
786785 *************************************************************************/
787786
788static UINT8 pc_HDC_r(int chip, offs_t offs)
787static UINT8 pc_HDC_r(running_machine *machine, int chip, offs_t offs)
789788{
790789   UINT8 data = 0xff;
791790
r3889r3890
798797   }
799798
800799   if (LOG_HDC_CALL)
801      logerror("pc_HDC_r(): pc=%06X chip=%d offs=%d result=0x%02x\n", cpu_get_pc(Machine->cpu[0]), chip, offs, data);
800      logerror("pc_HDC_r(): pc=%06X chip=%d offs=%d result=0x%02x\n", cpu_get_pc(machine->cpu[0]), chip, offs, data);
802801
803802   return data;
804803}
805804
806805
807806
808static void pc_HDC_w(int chip, offs_t offs, UINT8 data)
807static void pc_HDC_w(running_machine *machine, int chip, offs_t offs, UINT8 data)
809808{
810809   if (LOG_HDC_CALL)
811      logerror("pc_HDC_w(): pc=%06X chip=%d offs=%d data=0x%02x\n", cpu_get_pc(Machine->cpu[0]), chip, offs, data);
810      logerror("pc_HDC_w(): pc=%06X chip=%d offs=%d data=0x%02x\n", cpu_get_pc(machine->cpu[0]), chip, offs, data);
812811
813812   switch( offs )
814813   {
815      case 0: pc_hdc_data_w(chip,data);    break;
814      case 0: pc_hdc_data_w(machine, chip,data);    break;
816815      case 1: pc_hdc_reset_w(chip,data);    break;
817816      case 2: pc_hdc_select_w(chip,data);  break;
818      case 3: pc_hdc_control_w(chip,data); break;
817      case 3: pc_hdc_control_w(machine, chip, data); break;
819818   }
820819}
821820
r3889r3890
826825 *
827826 *************************************/
828827
829READ8_HANDLER ( pc_HDC1_r ) { return pc_HDC_r(0, offset); }
830READ8_HANDLER ( pc_HDC2_r ) { return pc_HDC_r(1, offset); }
831WRITE8_HANDLER ( pc_HDC1_w ) { pc_HDC_w(0, offset, data); }
832WRITE8_HANDLER ( pc_HDC2_w ) { pc_HDC_w(1, offset, data); }
828READ8_HANDLER ( pc_HDC1_r ) { return pc_HDC_r(space->machine, 0, offset); }
829READ8_HANDLER ( pc_HDC2_r ) { return pc_HDC_r(space->machine, 1, offset); }
830WRITE8_HANDLER ( pc_HDC1_w ) { pc_HDC_w(space->machine, 0, offset, data); }
831WRITE8_HANDLER ( pc_HDC2_w ) { pc_HDC_w(space->machine, 1, offset, data); }
833832
834833READ16_HANDLER ( pc16le_HDC1_r ) { return read16le_with_read8_handler(pc_HDC1_r, space, offset, mem_mask); }
835834READ16_HANDLER ( pc16le_HDC2_r ) { return read16le_with_read8_handler(pc_HDC2_r, space, offset, mem_mask); }
src/mess/machine/pc_hdc.h
r3889r3890
2020READ32_HANDLER  ( pc32le_HDC2_r );
2121WRITE32_HANDLER ( pc32le_HDC2_w );
2222
23int pc_hdc_dack_r(void);
24void pc_hdc_dack_w(int data);
23int pc_hdc_dack_r(running_machine *machine);
24void pc_hdc_dack_w(running_machine *machine,int data);
2525
2626void pc_hdc_set_dma8237_device( const device_config *dma8237 );
2727
src/mess/machine/pc.c
r3889r3890
130130
131131static DMA8237_CHANNEL_READ( pc_dma8237_hdc_dack_r )
132132{
133   return pc_hdc_dack_r();
133   return pc_hdc_dack_r( device->machine );
134134}
135135
136136
r3889r3890
142142
143143static DMA8237_CHANNEL_WRITE( pc_dma8237_hdc_dack_w )
144144{
145   pc_hdc_dack_w( data );
145   pc_hdc_dack_w( device->machine, data );
146146}
147147
148148

Previous 15994 Revisions Next


© 1998-2018 The MESS Team