src/mess/machine/x68k_hdc.c
| r2759 | r2760 | |
| 16 | 16 | */
|
| 17 | 17 | |
| 18 | 18 | #include "x68k_hdc.h"
|
| 19 | #include "devices/harddriv.h"
|
| 20 | #include "image.h"
|
| 19 | 21 | |
| 22 | struct hd_state hd;
|
| 23 | |
| 20 | 24 | static TIMER_CALLBACK( req_delay )
|
| 21 | 25 | {
|
| 22 | 26 | sasi_ctrl_t* sasi = ptr;
|
| r2759 | r2760 | |
| 24 | 28 | sasi->status_port |= 0x01;
|
| 25 | 29 | }
|
| 26 | 30 | |
| 31 | unsigned 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 | |
| 41 | void SASIWriteByte(const device_config* device, unsigned char val)
|
| 42 | {
|
| 43 | image_fwrite(device,&val,1);
|
| 44 | }
|
| 45 | |
| 27 | 46 | DEVICE_START( x68k_hdc )
|
| 28 | 47 | {
|
| 29 | 48 | sasi_ctrl_t* sasi = device->token;
|
| r2759 | r2760 | |
| 33 | 52 | sasi->status = 0x00;
|
| 34 | 53 | sasi->status_port = 0x00;
|
| 35 | 54 | sasi->phase = SASI_PHASE_BUSFREE;
|
| 55 | hd.current_block = 0;
|
| 36 | 56 | }
|
| 37 | 57 | |
| 38 | 58 | WRITE16_DEVICE_HANDLER( x68k_hdc_w )
|
| 39 | 59 | {
|
| 40 | 60 | sasi_ctrl_t* sasi = device->token;
|
| 61 | unsigned int lba = 0;
|
| 41 | 62 | |
| 42 | 63 | switch(offset)
|
| 43 | 64 | {
|
| r2759 | r2760 | |
| 51 | 72 | case SASI_CMD_SPECIFY:
|
| 52 | 73 | sasi->transfer_byte_total = 10;
|
| 53 | 74 | break;
|
| 75 | case SASI_CMD_WRITE:
|
| 76 | sasi->transfer_byte_total = (0x100 * sasi->command[4]);
|
| 77 | break;
|
| 54 | 78 | default:
|
| 55 | | sasi->transfer_byte_total = 0x800;
|
| 79 | sasi->transfer_byte_total = 0x100;
|
| 56 | 80 | }
|
| 57 | 81 | }
|
| 58 | | // TODO: Do something with written data
|
| 59 | 82 | |
| 60 | 83 | if(sasi->command[0] == SASI_CMD_SPECIFY)
|
| 61 | 84 | {
|
| 62 | 85 | logerror("SPECIFY: wrote 0x%02x\n",data);
|
| 63 | 86 | }
|
| 64 | 87 | |
| 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 | |
| 65 | 104 | sasi->req = 0;
|
| 66 | 105 | sasi->status_port &= ~0x01;
|
| 67 | 106 | timer_set(ATTOTIME_IN_NSEC(450),sasi,0,req_delay);
|
| r2759 | r2760 | |
| 108 | 147 | if(sasi->command_byte_count >= sasi->command_byte_total)
|
| 109 | 148 | {
|
| 110 | 149 | // End of command
|
| 111 | | // TODO: Actually execute SASI command
|
| 112 | 150 | |
| 113 | 151 | switch(sasi->command[0])
|
| 114 | 152 | {
|
| r2759 | r2760 | |
| 138 | 176 | sasi->transfer_byte_total = 0;
|
| 139 | 177 | logerror("SASI: SPECIFY\n");
|
| 140 | 178 | 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;
|
| 141 | 245 | default:
|
| 142 | 246 | sasi->phase = SASI_PHASE_STATUS;
|
| 143 | 247 | sasi->io = 1; // Output
|
| r2759 | r2760 | |
| 179 | 283 | break;
|
| 180 | 284 | }
|
| 181 | 285 | |
| 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);
|
| 183 | 287 | }
|
| 184 | 288 | |
| 185 | 289 | READ16_DEVICE_HANDLER( x68k_hdc_r )
|
| 186 | 290 | {
|
| 187 | 291 | sasi_ctrl_t* sasi = device->token;
|
| 188 | | int retval;
|
| 292 | int retval = 0xff;
|
| 189 | 293 | |
| 190 | 294 | switch(offset)
|
| 191 | 295 | {
|
| r2759 | r2760 | |
| 231 | 335 | else
|
| 232 | 336 | sasi->transfer_byte_total = sasi->command[3];
|
| 233 | 337 | break;
|
| 338 | case SASI_CMD_READ:
|
| 339 | sasi->transfer_byte_total = (0x100 * sasi->command[4]);
|
| 340 | sasi->transfer_byte_count = 0;
|
| 341 | break;
|
| 234 | 342 | default:
|
| 235 | 343 | sasi->transfer_byte_total = 0;
|
| 236 | 344 | }
|
| r2759 | r2760 | |
| 242 | 350 | retval = sasi->sense[sasi->transfer_byte_count];
|
| 243 | 351 | logerror("REQUEST SENSE: read value 0x%02x\n",retval);
|
| 244 | 352 | 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;
|
| 245 | 367 | default:
|
| 246 | 368 | retval = 0;
|
| 247 | 369 | }
|
| r2759 | r2760 | |
| 265 | 387 | }
|
| 266 | 388 | return 0x00;
|
| 267 | 389 | 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);
|
| 269 | 391 | return sasi->status_port;
|
| 270 | 392 | case 0x02:
|
| 271 | 393 | return 0xff; // write-only
|
| r2759 | r2760 | |
| 289 | 411 | switch (state)
|
| 290 | 412 | {
|
| 291 | 413 | /* --- 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;
|
| 293 | 415 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(sasi_ctrl_t); break;
|
| 416 | case DEVINFO_INT_IMAGE_TYPE: info->i = IO_HARDDISK; break;
|
| 294 | 417 | |
| 295 | 418 | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 296 | 419 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(x68k_hdc); break;
|
| 297 | 420 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(x68k_hdc); break;
|
| 298 | 421 | case DEVINFO_FCT_STOP: /* Nothing */ break;
|
| 299 | 422 | 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;
|
| 300 | 426 | |
| 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;
|
| 303 | 429 | case DEVINFO_STR_FAMILY: info->s = "SASI Hard Disk Controller"; break;
|
| 304 | 430 | case DEVINFO_STR_VERSION: info->s = "1.0"; break;
|
| 305 | 431 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break;
|
| 306 | 432 | 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;
|
| 307 | 437 | }
|
| 308 | 438 | }
|
| 309 | 439 | |
src/mess/drivers/x68k.c
| r2759 | r2760 | |
| 1594 | 1594 | static const hd63450_intf dmac_interface = |
| 1595 | 1595 | { |
| 1596 | 1596 | 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) |
| 1599 | 1599 | x68k_dma_end, |
| 1600 | 1600 | x68k_dma_error, |
| 1601 | 1601 | { x68k_fdc_read_byte, 0, 0, 0 }, |
| r2759 | r2760 | |
| 1906 | 1906 | } |
| 1907 | 1907 | } |
| 1908 | 1908 | |
| 1909 | | static 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 | | |
| 1931 | 1909 | static MACHINE_RESET( x68000 ) |
| 1932 | 1910 | { |
| 1933 | 1911 | /* The last half of the IPLROM is mapped to 0x000000 on reset only |
| r2759 | r2760 | |
| 2103 | 2081 | |
| 2104 | 2082 | SYSTEM_CONFIG_START(x68000) |
| 2105 | 2083 | CONFIG_DEVICE(x68k_floppy_getinfo) |
| 2106 | | CONFIG_DEVICE(x68k_sasihd_getinfo) |
| 2107 | 2084 | CONFIG_RAM(0x100000) |
| 2108 | 2085 | CONFIG_RAM(0x200000) |
| 2109 | 2086 | CONFIG_RAM(0x300000) |