Previous 15994 Revisions Next

r2655 Sunday 18th May, 2008 at 16:02:10 UTC by Wilbert Pol
[IBM5150,IBM5160] Partial hard disk support fixes. The ibm5160 still needs to have 2 hard disk images mounted.
[src/mess/machine]pc.c pc_hdc.c pc_hdc.h

src/mess/machine/pc_hdc.c
r2654r2655
1414   The format of the so called 'POD' (power on drive paramters?) area
1515   read from the MBR (master boot record) at offset 1AD to 1BD is wrong.
1616
17
18
19   There were a lot of different Fixed Disk Adapter for the IBM pcs.
20   Xebec produced a couple of the Fixed Disk Adapter for IBM.
21   
22   One Xebec Adapter has these roms on it:
23   One MK6xxxx ROM: 62X0822__(M)_AMI_8621MAB__S68B364-P__(C)IBM_CORP_1982,1985__PHILIPPINES.12D.2364.bin
24   One 2732 ROM for the Z80: 104839RE__COPYRIGHT__XEBEC_1986.12A.2732.bin
25
26
27   tandon Fixed Disk Adapter found in an IBM 5150:
28   600963-001__TYPE_5.U12.2764.bin
29
1730***************************************************************************/
1831
19#include <stdio.h>
20
2132#include "driver.h"
22#include "deprecat.h"
2333#include "machine/pc_hdc.h"
24#include "machine/pic8259.h"
2534#include "machine/8237dma.h"
2635#include "devices/harddriv.h"
2736#include "memconv.h"
r2654r2655
7382
7483/* XT hard disk controller control bits */
7584#define CTL_PIO       0x00
76#define CTL_DMA       0x03
85#define CTL_DMA       0x01
7786
7887static int idx = 0;                      /* contoller * 2 + drive */
7988static int drv = 0;                      /* 0 master, 1 slave drive */
r2654r2655
99108
100109static int data_cnt = 0;                /* data count */
101110static UINT8 *buffer;               /* data buffer */
102static UINT8 *ptr = 0;               /* data pointer */
111static UINT8 *buffer_ptr = 0;         /* data pointer */
103112static UINT8 hdc_control;
104113static void (*hdc_set_irq)(int,int);
114static const device_config *pc_hdc_dma8237;
105115
116
106117static const char *const hdc_command_names[] =
107118{
108119   "CMD_TESTREADY",      /* 0x00 */
r2654r2655
182193      status[i] = 0;
183194      error[i] = 0;
184195      dip[i] = 0xff;
196      pc_hdc_dma8237 = NULL;
185197      timer[i] = timer_alloc(pc_hdc_command, NULL);
186198      if (!timer[i])
187199         return -1;
r2654r2655
189201   return 0;
190202}
191203
204
205void pc_hdc_set_dma8237_device( const device_config *dma8237 )
206{
207   pc_hdc_dma8237 = dma8237;
208}
209
210
192211static hard_disk_file *pc_hdc_file(int id)
193212{
194213   const device_config *img;
r2654r2655
200219   return mess_hd_get_hard_disk_file(img);
201220}
202221
203static void pc_hdc_result(int n)
222static void pc_hdc_result(int n, int set_error_info)
204223{
205224   int irq;
206225
207226   /* dip switch selected INT 5 or 2 */
208227   irq = (dip[n] & 0x40) ? 5 : 2;
209228
210   if ( hdc_set_irq ) {
229   if ( ( hdc_control & 0x02 ) && hdc_set_irq ) {
211230      hdc_set_irq( irq, 1 );
212      hdc_set_irq( irq, 0 );
213231   }
214232
215233   if (LOG_HDC_STATUS)
r2654r2655
217235
218236   buffer[data_cnt++] = csb[n];
219237
220   if (csb[n] & CSB_ERROR)
238   if (set_error_info && ( csb[n] & CSB_ERROR ) )
221239   {
222240        buffer[data_cnt++] = error[n];
223241      if (error[n] & 0x80)
r2654r2655
385403   }
386404   else
387405   {
388      dma8237_run_transfer(0, HDC_DMA);
406      dma8237_run_transfer(pc_hdc_dma8237, HDC_DMA);
389407   }
390408}
391409
r2654r2655
417435   }
418436   else
419437   {
420      dma8237_run_transfer(0, HDC_DMA);
438      dma8237_run_transfer(pc_hdc_dma8237, HDC_DMA);
421439   }
422440}
423441
r2654r2655
458476static TIMER_CALLBACK(pc_hdc_command)
459477{
460478   int n = param;
479   int set_error_info = 1;
480   int old_error = error[n];         /* Previous error data is needed for CMD_SENSE */
481   int old_csb = csb[n];
461482   UINT8 cmd;
462483   const char *command_name;
463484
464485   csb[n] = 0x00;
465486   error[n] = 0;
466487
467   ptr = buffer;
488   buffer_ptr = buffer;
468489   cmd = buffer[0];
469490
491   get_drive(n);
492
470493   if (LOG_HDC_STATUS)
471494   {
472495      command_name = hdc_command_names[cmd] ? hdc_command_names[cmd] : "Unknown";
r2654r2655
477500   switch (cmd)
478501   {
479502      case CMD_TESTREADY:
480      case CMD_SENSE:
481         get_drive(n);
503         set_error_info = 0;
482504         test_ready(n);
483505            break;
506      case CMD_SENSE:
507         error[n] = old_error;
508         csb[n] = old_csb;
509         /* Perform error code translation. This may need to be expanded in the future. */
510         buffer[data_cnt++] = ( error[n] & 0xC0 ) | ( ( error[n] & 0x04 ) ? 0x04 : 0x00 ) ;
511         buffer[data_cnt++] = (drv << 5) | head[idx];
512         buffer[data_cnt++] = ((cylinder[idx] >> 2) & 0xc0) | sector[idx];
513         buffer[data_cnt++] = cylinder[idx] & 0xff;
514         set_error_info = 0;
515         break;
484516      case CMD_RECALIBRATE:
485         get_drive(n);
486517         get_chsn(n);
487/*         test_ready(n); */
518         test_ready(n);
519         set_error_info = 0;
488520            break;
489521
490522      case CMD_FORMATDRV:
r2654r2655
493525      case CMD_FORMATBAD:
494526      case CMD_SEEK:
495527      case CMD_DRIVEDIAG:
496         get_drive(n);
497528         get_chsn(n);
498529         test_ready(n);
499530            break;
500531
501532      case CMD_READ:
502533      case CMD_READLONG:
503         get_drive(n);
504534         get_chsn(n);
505535
506536         if (LOG_HDC_STATUS)
r2654r2655
511541
512542         if (test_ready(n))
513543            execute_read();
544         set_error_info = 0;
514545         break;
515546
516547      case CMD_WRITE:
517548      case CMD_WRITELONG:
518         get_drive(n);
519549         get_chsn(n);
520550
521551         if (LOG_HDC_STATUS)
r2654r2655
529559         break;
530560
531561      case CMD_SETPARAM:
532         get_drive(n);
533562         get_chsn(n);
534563         cylinders[idx] = ((buffer[6]&3)<<8) | buffer[7];
535564         heads[idx] = buffer[8] & 0x1f;
r2654r2655
549578         break;
550579
551580   }
552   pc_hdc_result(n);
581   pc_hdc_result(n, set_error_info);
553582}
554583
555584
r2654r2655
580609      if (LOG_HDC_DATA)
581610         logerror("hdc_data_w BOARD #%d $%02x: ", n, data);
582611
583        ptr = buffer;
612        buffer_ptr = buffer;
584613      data_cnt = 6;   /* expect 6 bytes including this one */
585614      status[n] &= ~STA_READY;
586615      status[n] &= ~STA_INPUT;
r2654r2655
614643            data_cnt = 0;
615644            status[n] |= STA_INPUT;
616645            csb[n] |= CSB_ERROR | 0x20; /* unknown command */
617            pc_hdc_result(n);
646            pc_hdc_result(n, 1);
618647            break;
619648      }
620649      if( data_cnt )
r2654r2655
626655      if (LOG_HDC_DATA)
627656         logerror("hdc_data_w BOARD #%d $%02x\n", n, data);
628657
629      *ptr++ = data;
658      *buffer_ptr++ = data;
630659      status[n] |= STA_READY;
631660      if (--data_cnt == 0)
632661      {
r2654r2655
654683   csb[n] = 0;
655684   status[n] = STA_COMMAND | STA_READY;
656685   memset(buffer, 0, sizeof(buffer));
657   ptr = buffer;
686   buffer_ptr = buffer;
658687   data_cnt = 0;
659688}
660689
r2654r2655
670699
671700static void pc_hdc_control_w(int n, int data)
672701{
702   int irq = irq = (dip[n] & 0x40) ? 5 : 2;
703
673704   if (LOG_HDC_STATUS)
674705      logerror("pc_hdc_control_w(): Control write pc=0x%08x data=%d\n", (unsigned) cpunum_get_reg(0, REG_PC), data);
675706
676707   hdc_control = data;
708
709   if ( ! ( hdc_control & 0x02 ) && hdc_set_irq ) {
710      hdc_set_irq( irq, 0 );
711   }
677712}
678713
679714
r2654r2655
683718   UINT8 data = 0xff;
684719   if( data_cnt )
685720   {
686      data = *ptr++;
721      data = *buffer_ptr++;
687722      status[n] &= ~STA_INTERRUPT;
688723      if( --data_cnt == 0 )
689724      {
r2654r2655
706741
707742
708743
744/*
745   Dipswitch configuration
746
747
748   Tandon/Western Digital Fixed Disk Controller
749   bit0-1 : Determine disk size(?)
750      Causes geometry data to be read from c8043, c8053, c8063, c8073 (?)
751      00 - 40 Mbytes
752      01 - 30 Mbytes
753      10 - 10 Mbytes
754      11 - 20 Mbytes
755   bit2-7 : unknown
756
757 */
758
709759static UINT8 pc_hdc_dipswitch_r(int n)
710760{
711761   int data = dip[n];
r2654r2655
724774static UINT8 pc_HDC_r(int chip, offs_t offs)
725775{
726776   UINT8 data = 0xff;
727   if( !(input_port_read_indexed(Machine, 3) & (0x08>>chip)) || !pc_hdc_file(chip<<1) )
728      return data;
777
729778   switch( offs )
730779   {
731780      case 0: data = pc_hdc_data_r(chip);     break;
r2654r2655
735784   }
736785
737786   if (LOG_HDC_CALL)
738      logerror("pc_HDC_r(): chip=%d offs=%d result=0x%02x\n", chip, offs, data);
787      logerror("pc_HDC_r(): pc=%06X chip=%d offs=%d result=0x%02x\n", activecpu_get_pc(), chip, offs, data);
739788
740789   return data;
741790}
r2654r2655
745794static void pc_HDC_w(int chip, offs_t offs, UINT8 data)
746795{
747796   if (LOG_HDC_CALL)
748      logerror("pc_HDC_w(): chip=%d offs=%d data=0x%02x\n", chip, offs, data);
797      logerror("pc_HDC_w(): pc=%06X chip=%d offs=%d data=0x%02x\n", activecpu_get_pc(), chip, offs, data);
749798
750   if( !(input_port_read_indexed(Machine, 3) & (0x08>>chip)) || !pc_hdc_file(chip<<1) )
751      return;
752
753799   switch( offs )
754800   {
755801      case 0: pc_hdc_data_w(chip,data);    break;
src/mess/machine/pc_hdc.h
r2654r2655
2323int pc_hdc_dack_r(void);
2424void pc_hdc_dack_w(int data);
2525
26void pc_hdc_set_dma8237_device( const device_config *dma8237 );
27
2628#endif /* PC_HDC_H */
src/mess/machine/pc.c
r2654r2655
5757static struct {
5858   const device_config   *pic8259_master;
5959   const device_config   *pic8259_slave;
60   const device_config   *dma8237_1;
61   const device_config   *dma8237_2;
60   const device_config   *dma8237;
6261} pc_devices;
6362
6463/*************************************************************************
r2654r2655
783782
784783static void pc_fdc_dma_drq(int state, int read_)
785784{
786   dma8237_drq_write( (device_config*)device_list_find_by_tag( Machine->config->devicelist, DMA8237, "dma8237" ), FDC_DMA, state);
785   dma8237_drq_write( pc_devices.dma8237, FDC_DMA, state);
787786}
788787
789788
r2654r2655
10141013
10151014   pc_devices.pic8259_master = device_list_find_by_tag( machine->config->devicelist, PIC8259, "pic8259_master" );
10161015   pc_devices.pic8259_slave = device_list_find_by_tag( machine->config->devicelist, PIC8259, "pic8259_slave" );
1017   pc_devices.dma8237_1 = device_list_find_by_tag( machine->config->devicelist, DMA8237, "dma8237_1" );
1018   pc_devices.dma8237_2 = device_list_find_by_tag( machine->config->devicelist, DMA8237, "dma8237_2" );
1016   pc_devices.dma8237 = device_list_find_by_tag( machine->config->devicelist, DMA8237, "dma8237" );
10191017   pc_mouse_set_serial_port( device_list_find_by_tag( machine->config->devicelist, INS8250, "ins8250_0" ) );
1018   pc_hdc_set_dma8237_device( pc_devices.dma8237 );
10201019}
10211020
10221021
r2654r2655
10821081INTERRUPT_GEN( pc_frame_interrupt )
10831082{
10841083   pc_keyboard();
1084
1085   /* Extermely crappy hack to have let the ibm5150 support 640kb. For testing purposes only. */
1086//   if ( mess_ram[0x413] == 0x00 && mess_ram[0x414] == 0x01 )
1087//   {
1088//      mess_ram[0x413] = 640 & 0xff;
1089//      mess_ram[0x414] = 640 >> 8;
1090//   }
1091
10851092}
10861093
10871094INTERRUPT_GEN( pc_vga_frame_interrupt )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team