Previous 15994 Revisions Next

r2760 Thursday 29th May, 2008 at 02:19:04 UTC by Barry Rodewald
[X68000] Added basic implementation of Read, Write amd Seek SASI commands. Bootable hard disk images can now be booted.
[docs]messnew.txt
[src/mess/drivers]x68k.c
[src/mess/machine]hd63450.c x68k_hdc.c x68k_hdc.h

src/mess/machine/x68k_hdc.c
r2759r2760
1616*/
1717 
1818#include "x68k_hdc.h"
19#include "devices/harddriv.h"
20#include "image.h"
1921 
22struct hd_state hd;
23 
2024static TIMER_CALLBACK( req_delay )
2125{
2226   sasi_ctrl_t* sasi = ptr;
r2759r2760
2428   sasi->status_port |= 0x01;
2529}
2630 
31unsigned char SASIReadByte(const device_config* device)
32{
33   int ret;
34   unsigned char val;
35 
36   ret = image_fread(device,&val,1);
37   
38   return val;
39}
40 
41void SASIWriteByte(const device_config* device, unsigned char val)
42{
43   image_fwrite(device,&val,1);
44}
45 
2746DEVICE_START( x68k_hdc )
2847{
2948   sasi_ctrl_t* sasi = device->token;
r2759r2760
3352   sasi->status = 0x00;
3453   sasi->status_port = 0x00;
3554   sasi->phase = SASI_PHASE_BUSFREE;
55   hd.current_block = 0;
3656}
3757 
3858WRITE16_DEVICE_HANDLER( x68k_hdc_w )
3959{
4060   sasi_ctrl_t* sasi = device->token;
61   unsigned int lba = 0;
4162 
4263   switch(offset)
4364   {
r2759r2760
5172            case SASI_CMD_SPECIFY:
5273               sasi->transfer_byte_total = 10;
5374               break;
75            case SASI_CMD_WRITE:
76               sasi->transfer_byte_total = (0x100 * sasi->command[4]);
77               break;
5478            default:
55               sasi->transfer_byte_total = 0x800;
79               sasi->transfer_byte_total = 0x100;
5680            }
5781         }
58         // TODO: Do something with written data
5982 
6083         if(sasi->command[0] == SASI_CMD_SPECIFY)
6184         {
6285            logerror("SPECIFY: wrote 0x%02x\n",data);
6386         }
6487 
88         if(sasi->command[0] == SASI_CMD_WRITE)
89         {
90            if(!image_exists(device))
91            {
92               sasi->phase = SASI_PHASE_STATUS;
93               sasi->io = 1;  // Output
94               sasi->status_port |= 0x04;  // C/D remains the same
95               sasi->status = 0x02;
96               logerror("SASI: No HD connected.\n");
97            }
98            else
99            {
100               SASIWriteByte(device,data);
101            }
102         }
103 
65104         sasi->req = 0;
66105         sasi->status_port &= ~0x01;
67106         timer_set(ATTOTIME_IN_NSEC(450),sasi,0,req_delay);
r2759r2760
108147         if(sasi->command_byte_count >= sasi->command_byte_total)
109148         {
110149            // End of command
111            // TODO: Actually execute SASI command
112150 
113151            switch(sasi->command[0])
114152            {
r2759r2760
138176               sasi->transfer_byte_total = 0;
139177               logerror("SASI: SPECIFY\n");
140178               break;
179            case SASI_CMD_READ:
180               if(!image_exists(device))
181               {
182                  sasi->phase = SASI_PHASE_STATUS;
183                  sasi->io = 1;  // Output
184                  sasi->status_port |= 0x04;  // C/D remains the same
185                  sasi->cd = 1;
186                  sasi->status_port |= 0x08;
187                  sasi->status = 0x02;
188                  logerror("SASI: No HD connected\n");
189               }
190               else
191               {
192                  sasi->phase = SASI_PHASE_READ;
193                  sasi->io = 1;
194                  sasi->status_port |= 0x04;
195                  sasi->cd = 0;
196                  sasi->status_port &= ~0x08;
197                  sasi->transfer_byte_count = 0;
198                  sasi->transfer_byte_total = 0;
199                  lba = sasi->command[3];
200                  lba |= sasi->command[2] << 8;
201                  lba |= (sasi->command[1] & 0x1f) << 16;
202                  image_fseek(device,lba * 256,SEEK_SET);
203                  logerror("SASI: READ (LBA 0x%06x, blocks = %i)\n",lba,sasi->command[4]);
204               }
205               break;
206            case SASI_CMD_WRITE:
207               if(!image_exists(device))
208               {
209                  sasi->phase = SASI_PHASE_STATUS;
210                  sasi->io = 1;  // Output
211                  sasi->status_port |= 0x04;  // C/D remains the same
212                  sasi->cd = 1;
213                  sasi->status_port |= 0x08;
214                  sasi->status = 0x02;
215                  logerror("SASI: No HD connected\n");
216               }
217               else
218               {
219                  sasi->phase = SASI_PHASE_WRITE;
220                  sasi->io = 0;
221                  sasi->status_port &= ~0x04;
222                  sasi->cd = 0;
223                  sasi->status_port &= ~0x08;
224                  sasi->transfer_byte_count = 0;
225                  sasi->transfer_byte_total = 0;
226                  lba = sasi->command[3];
227                  lba |= sasi->command[2] << 8;
228                  lba |= (sasi->command[1] & 0x1f) << 16;
229                  image_fseek(device,lba * 256,SEEK_SET);
230                  logerror("SASI: WRITE (LBA 0x%06x, blocks = %i)\n",lba,sasi->command[4]);
231               }
232               break;
233            case SASI_CMD_SEEK:
234                  sasi->phase = SASI_PHASE_STATUS;
235                  sasi->io = 1;  // Output
236                  sasi->status_port |= 0x04;  // C/D remains the same
237                  sasi->cd = 1;
238                  sasi->status_port |= 0x08;
239                  lba = sasi->command[3];
240                  lba |= sasi->command[2] << 8;
241                  lba |= (sasi->command[1] & 0x1f) << 16;
242                  image_fseek(device,lba * 256,SEEK_SET);
243                  logerror("SASI: SEEK (LBA 0x%06x)\n",lba);
244               break;
141245            default:
142246               sasi->phase = SASI_PHASE_STATUS;
143247               sasi->io = 1;  // Output
r2759r2760
179283      break;
180284   }
181285 
182   logerror("SASI: write to HDC, offset %04x, data %04x\n",offset,data);
286//   logerror("SASI: write to HDC, offset %04x, data %04x\n",offset,data);
183287}
184288 
185289READ16_DEVICE_HANDLER( x68k_hdc_r )
186290{
187291   sasi_ctrl_t* sasi = device->token;
188   int retval;
292   int retval = 0xff;
189293 
190294   switch(offset)
191295   {
r2759r2760
231335               else
232336                  sasi->transfer_byte_total = sasi->command[3];
233337               break;
338            case SASI_CMD_READ:
339               sasi->transfer_byte_total = (0x100 * sasi->command[4]);
340               sasi->transfer_byte_count = 0;
341               break;
234342            default:
235343               sasi->transfer_byte_total = 0;
236344            }
r2759r2760
242350            retval = sasi->sense[sasi->transfer_byte_count];
243351            logerror("REQUEST SENSE: read value 0x%02x\n",retval);
244352            break;
353         case SASI_CMD_READ:
354            if(!image_exists(device))
355            {
356               sasi->phase = SASI_PHASE_STATUS;
357               sasi->io = 1;  // Output
358               sasi->status_port |= 0x04;  // C/D remains the same
359               sasi->status = 0x02;
360               logerror("SASI: No HD connected.\n");
361            }
362            else
363            {
364               retval = SASIReadByte(device);
365            }
366            break;
245367         default:
246368            retval = 0;
247369         }
r2759r2760
265387      }
266388      return 0x00;
267389   case 0x01:
268      logerror("SASI: [%08x] read from status port, read 0x%02x\n",activecpu_get_pc(),sasi->status_port);
390//      logerror("SASI: [%08x] read from status port, read 0x%02x\n",activecpu_get_pc(),sasi->status_port);
269391      return sasi->status_port;
270392   case 0x02:
271393      return 0xff;  // write-only
r2759r2760
289411   switch (state)
290412   {
291413      /* --- the following bits of info are returned as 64-bit signed integers --- */
292      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_OTHER;            break;
414      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;            break;
293415      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(sasi_ctrl_t);            break;
416      case DEVINFO_INT_IMAGE_TYPE:               info->i = IO_HARDDISK; break;
294417 
295418      /* --- the following bits of info are returned as pointers to data or functions --- */
296419      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(x68k_hdc); break;
297420      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(x68k_hdc);   break;
298421      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
299422      case DEVINFO_FCT_RESET:                     /*info->reset = DEVICE_RESET_NAME(x68k_hdc);*/   break;
423      case DEVINFO_INT_IMAGE_READABLE:            info->i = 1; break;
424      case DEVINFO_INT_IMAGE_WRITEABLE:            info->i = 1; break;
425      case DEVINFO_INT_IMAGE_CREATABLE:            info->i = 0; break;
300426 
301      /* --- the following bits of info are returned as NULL-terminated strings --- */
302      case DEVINFO_STR_NAME:                     info->s = "X68000 SASI Hard Disk Controller";   break;
427         /* --- the following bits of info are returned as NULL-terminated strings --- */
428      case DEVINFO_STR_NAME:                     info->s = "SASI Hard Disk";   break;
303429      case DEVINFO_STR_FAMILY:                  info->s = "SASI Hard Disk Controller";         break;
304430      case DEVINFO_STR_VERSION:                  info->s = "1.0";                     break;
305431      case DEVINFO_STR_SOURCE_FILE:               info->s = __FILE__;                     break;
306432      case DEVINFO_STR_CREDITS:                  info->s = "Copyright the MESS Team";       break;
433      case MESS_DEVINFO_STR_NAME:                  info->s = "sasihd";          break;
434      case MESS_DEVINFO_STR_SHORT_NAME:            info->s = "sasi";          break;
435      case MESS_DEVINFO_STR_DESCRIPTION:            info->s = "SASI Hard Disk";          break;
436      case DEVINFO_STR_IMAGE_FILE_EXTENSIONS:         info->s = "hdf"; break;
307437   }
308438}
309439 
src/mess/machine/x68k_hdc.h
r2759r2760
9696   int req;  // REQ
9797};
9898 
99struct hd_state
100{
101   int current_block;
102   int current_pos;
103};
104 
105unsigned char SASIReadByte(const device_config* device);
106 
99107DEVICE_START( x68k_hdc );
100108DEVICE_GET_INFO( x68k_hdc );
101109 
110DEVICE_IMAGE_LOAD( sasihd );
111DEVICE_IMAGE_UNLOAD( sasihd );
112 
102113#define X68KHDC DEVICE_GET_INFO_NAME(x68k_hdc)
103114 
104115WRITE16_DEVICE_HANDLER( x68k_hdc_w );
src/mess/machine/hd63450.c
r2759r2760
337337                  break;
338338               case 0x30:  // 8 bit packed (?)
339339                  data = program_read_byte(dmac->reg[x].mar);  // read from memory address
340                  //program_write_byte(dmac->reg[x].dar, data);  // write to device address  -- disabled for now
340                  program_write_byte(dmac->reg[x].dar, data);  // write to device address
341341                  datasize = 1;
342342                  break;
343343               }
src/mess/drivers/x68k.c
r2759r2760
15941594static const hd63450_intf dmac_interface =
15951595{
15961596   0,  // CPU - 68000
1597   {STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_USEC(4),STATIC_ATTOTIME_IN_USEC(32)},  // Cycle steal mode timing (guesstimate)
1598   {STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_NSEC(50),STATIC_ATTOTIME_IN_NSEC(50),STATIC_ATTOTIME_IN_NSEC(50)}, // Burst mode timing (guesstimate)
1597   {STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_NSEC(450),STATIC_ATTOTIME_IN_USEC(4),STATIC_ATTOTIME_IN_USEC(32)},  // Cycle steal mode timing (guesstimate)
1598   {STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_NSEC(450),STATIC_ATTOTIME_IN_NSEC(50),STATIC_ATTOTIME_IN_NSEC(50)}, // Burst mode timing (guesstimate)
15991599   x68k_dma_end,
16001600   x68k_dma_error,
16011601   { x68k_fdc_read_byte, 0, 0, 0 },
r2759r2760
19061906   }
19071907}
19081908
1909static void x68k_sasihd_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
1910{
1911   switch(state)
1912   {
1913   case MESS_DEVINFO_INT_COUNT:
1914      info->i = 1;
1915      break;
1916   case MESS_DEVINFO_STR_NAME:         
1917      strcpy(info->s = device_temp_str(), "sasihd");
1918      break;
1919   case MESS_DEVINFO_STR_SHORT_NAME:               
1920      strcpy(info->s = device_temp_str(), "sasi");
1921      break;
1922   case MESS_DEVINFO_STR_DESCRIPTION:               
1923      strcpy(info->s = device_temp_str(), "SASI Hard Disk");
1924      break;
1925   default:
1926      harddisk_device_getinfo(devclass, state, info);
1927      break;
1928   }
1929}
1930
19311909static MACHINE_RESET( x68000 )
19321910{
19331911   /* The last half of the IPLROM is mapped to 0x000000 on reset only
r2759r2760
21032081
21042082SYSTEM_CONFIG_START(x68000)
21052083   CONFIG_DEVICE(x68k_floppy_getinfo)
2106   CONFIG_DEVICE(x68k_sasihd_getinfo)
21072084   CONFIG_RAM(0x100000)
21082085   CONFIG_RAM(0x200000)
21092086   CONFIG_RAM(0x300000)
docs/messnew.txt
r2759r2760
8484
8585- [UT88] Added SHA-1's.  [Fabio Priuli]
8686
87- [X68000] Added basic SASI hard disk support [Barry Rodewald]:
88  Currently supported SASI commands:
89  * Rezero Unit
90  * Specify
91  * Request Sense
92  * Read
93  * Write
94  * Seek
95
8796- [ZX81] Consolidated variants to use alternative BIOSes.  [Fabio Priuli]
8897
8998

Previous 15994 Revisions Next


© 1998-2018 The MESS Team