Previous 15994 Revisions Next

r2806 Tuesday 3rd June, 2008 at 08:11:59 UTC by Barry Rodewald
[X68000] Implemented Format Unit SASI command, and added a simple hard disk create function.
[src/mess/machine]x68k_hdc.c x68k_hdc.h

src/mess/machine/x68k_hdc.c
r2805r2806
1717
1818#include "x68k_hdc.h"
1919#include "devices/harddriv.h"
20#include "device.h"
2021#include "image.h"
2122
2223struct hd_state hd;
r2805r2806
5556   hd.current_block = 0;
5657}
5758
59DEVICE_IMAGE_CREATE( sasihd )
60{
61   // create 20MB HD
62   int x;
63   int ret;
64   unsigned char sectordata[256];  // empty block data
65
66   memset(sectordata,0,256);
67   for(x=0;x<0x013c98;x++)  // 0x13c98 = number of blocks on a 20MB HD
68   {
69      ret = image_fwrite(image,sectordata,256);
70      if(ret < 256)
71         return INIT_FAIL;
72   }
73
74   return INIT_PASS;
75}
76
5877WRITE16_DEVICE_HANDLER( x68k_hdc_w )
5978{
6079   sasi_ctrl_t* sasi = device->token;
6180   unsigned int lba = 0;
81   char* blk;
6282
6383   switch(offset)
6484   {
r2805r2806
236256                  sasi->status_port |= 0x04;  // C/D remains the same
237257                  sasi->cd = 1;
238258                  sasi->status_port |= 0x08;
259                  logerror("SASI: SEEK (LBA 0x%06x)\n",lba);
260               break;
261            case SASI_CMD_FORMAT_UNIT:
262            case SASI_CMD_FORMAT_UNIT_06:
263               /*
264                  Format Unit command format  (differs from SASI spec?)
265                  0 |   0x06
266                  1 |   Unit number (0-7) | LBA MSB (high 5 bits)
267                  2 |   LBA
268                  3 |   LBA LSB
269                  4 |   ??  (usually 0x01)
270                  5 |   ??
271               */
272                  sasi->phase = SASI_PHASE_STATUS;
273                  sasi->io = 1;  // Output
274                  sasi->status_port |= 0x04;  // C/D remains the same
275                  sasi->cd = 1;
276                  sasi->status_port |= 0x08;
239277                  lba = sasi->command[3];
240278                  lba |= sasi->command[2] << 8;
241279                  lba |= (sasi->command[1] & 0x1f) << 16;
242280                  image_fseek(device,lba * 256,SEEK_SET);
243                  logerror("SASI: SEEK (LBA 0x%06x)\n",lba);
281                  blk = malloc(256*33);
282                  memset(blk,0,256*33);
283                  // formats 33 256-byte blocks
284                  image_fwrite(device,blk,256*33);
285                  free(blk);
286                  logerror("SASI: FORMAT UNIT (LBA 0x%06x)\n",lba);
244287               break;
245288            default:
246289               sasi->phase = SASI_PHASE_STATUS;
r2805r2806
414457      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;            break;
415458      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(sasi_ctrl_t);            break;
416459      case DEVINFO_INT_IMAGE_TYPE:               info->i = IO_HARDDISK; break;
460      case DEVINFO_INT_IMAGE_READABLE:            info->i = 1; break;
461      case DEVINFO_INT_IMAGE_WRITEABLE:            info->i = 1; break;
462      case DEVINFO_INT_IMAGE_CREATABLE:            info->i = 1; break;
417463
418464      /* --- the following bits of info are returned as pointers to data or functions --- */
419465      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(x68k_hdc); break;
420466      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(x68k_hdc);   break;
421467      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
422468      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;
469      case DEVINFO_FCT_IMAGE_CREATE:               info->f = (genf *)DEVICE_IMAGE_CREATE_NAME(sasihd);   break;
426470
427471         /* --- the following bits of info are returned as NULL-terminated strings --- */
428472      case DEVINFO_STR_NAME:                     info->s = "SASI Hard Disk";   break;
src/mess/machine/x68k_hdc.h
r2805r2806
3030   SASI_CMD_REQUEST_SENSE,
3131   SASI_CMD_FORMAT_UNIT,
3232   SASI_CMD_RESERVED_05,
33   SASI_CMD_RESERVED_06,
33   SASI_CMD_FORMAT_UNIT_06,  // the X68000 uses command 0x06 for Format Unit, despite the SASI specs saying 0x04
3434   SASI_CMD_RESERVED_07,
3535   SASI_CMD_READ,
3636   SASI_CMD_RESERVED_09,
r2805r2806
107107DEVICE_START( x68k_hdc );
108108DEVICE_GET_INFO( x68k_hdc );
109109
110DEVICE_IMAGE_LOAD( sasihd );
111DEVICE_IMAGE_UNLOAD( sasihd );
110DEVICE_IMAGE_CREATE( sasihd );
112111
113112#define X68KHDC DEVICE_GET_INFO_NAME(x68k_hdc)
114113

Previous 15994 Revisions Next


© 1998-2018 The MESS Team