fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

atari: Support ICD ACSI host adapters

Hampa Hug f6c19ead 9bdca485

+139 -27
+136 -25
src/arch/atarist/acsi.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/arch/atarist/acsi.c * 7 7 * Created: 2013-06-04 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2013 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2013-2014 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 134 134 return (dsk); 135 135 } 136 136 137 + static 138 + void st_acsi_reset_cmd (st_acsi_t *acsi) 139 + { 140 + acsi->cmd_cnt = 0; 141 + acsi->cmd_max = 0; 142 + } 143 + 137 144 /* 138 - * CMD 00: TEST UNIT READY 145 + * CMD 00: TEST UNIT READY(6) 139 146 */ 140 147 static 141 148 void st_acsi_cmd_00 (st_acsi_t *acsi) ··· 155 162 } 156 163 157 164 /* 158 - * CMD 03: REQUEST SENSE 165 + * CMD 03: REQUEST SENSE(6) 159 166 */ 160 167 static 161 168 void st_acsi_cmd_03 (st_acsi_t *acsi) ··· 177 184 } 178 185 179 186 /* 180 - * CMD 04: FORMAT 187 + * CMD 04: FORMAT(6) 181 188 */ 182 189 static 183 190 void st_acsi_cmd_04 (st_acsi_t *acsi) ··· 192 199 } 193 200 194 201 /* 195 - * CMD 08: READ 202 + * CMD 08: READ(6) 196 203 */ 197 204 static 198 205 void st_acsi_cmd_08 (st_acsi_t *acsi) ··· 248 255 } 249 256 250 257 /* 251 - * CMD 0A: WRITE 258 + * CMD 0A: WRITE(6) 252 259 */ 253 260 static 254 261 void st_acsi_cmd_0a (st_acsi_t *acsi) ··· 277 284 acsi->result = 0; 278 285 } 279 286 280 - /* 281 - * CMD 12: INQUIRY 282 - */ 283 287 static 284 - void st_acsi_cmd_12 (st_acsi_t *acsi) 288 + void st_acsi_cmd_inquiry (st_acsi_t *acsi, unsigned cnt) 285 289 { 286 - unsigned cnt; 287 - disk_t *dsk; 288 - 289 - #if DEBUG_ACSI >= 1 290 - st_log_deb ("ACSI: CMD[%X/%02X] INQUIRY (n=%u)\n", 291 - acsi->cmd[0] >> 5, acsi->cmd[0] & 0x1f, acsi->cmd[4] 292 - ); 293 - #endif 290 + disk_t *dsk; 294 291 295 292 if ((dsk = st_acsi_get_disk (acsi)) == NULL) { 296 293 st_acsi_set_result (acsi, 0x04); 297 294 return; 298 295 } 299 - 300 - cnt = acsi->cmd[4]; 301 296 302 297 memset (acsi->buf, 0, 256); 303 298 memcpy (acsi->buf + 8, "PCE ", 8); ··· 312 307 acsi->result = 0; 313 308 } 314 309 310 + /* 311 + * CMD 12: INQUIRY(6) 312 + */ 313 + static 314 + void st_acsi_cmd_12 (st_acsi_t *acsi) 315 + { 316 + #if DEBUG_ACSI >= 1 317 + st_log_deb ("ACSI: CMD[%X/%02X] INQUIRY (n=%u)\n", 318 + acsi->cmd[0] >> 5, acsi->cmd[0] & 0x1f, acsi->cmd[4] 319 + ); 320 + #endif 321 + 322 + st_acsi_cmd_inquiry (acsi, acsi->cmd[4]); 323 + } 324 + 315 325 static 316 326 void st_acsi_cmd_15_cont (st_acsi_t *acsi) 317 327 { ··· 442 452 } 443 453 } 444 454 455 + /* 456 + * CMD 1F/12: INQUIRY(6) 457 + */ 458 + static 459 + void st_acsi_cmd_1f_12 (st_acsi_t *acsi) 460 + { 461 + #if DEBUG_ACSI >= 1 462 + st_log_deb ("ACSI: CMD[%X/1F/%02X] INQUIRY (n=%u)\n", 463 + acsi->cmd[0] >> 5, acsi->cmd[1], acsi->cmd[5] 464 + ); 465 + #endif 466 + 467 + st_acsi_cmd_inquiry (acsi, acsi->cmd[5]); 468 + } 469 + 470 + /* 471 + * CMD 1F/25: READ CAPACITY(10) 472 + */ 473 + static 474 + void st_acsi_cmd_1f_25 (st_acsi_t *acsi) 475 + { 476 + unsigned long cnt; 477 + disk_t *dsk; 478 + 479 + #if DEBUG_ACSI >= 1 480 + st_log_deb ("ACSI: CMD[%X/1F/%02X] READ CAPACITY\n", 481 + acsi->cmd[0] >> 5, acsi->cmd[1] 482 + ); 483 + #endif 484 + 485 + if ((dsk = st_acsi_get_disk (acsi)) == NULL) { 486 + st_acsi_set_result (acsi, 0x04); 487 + return; 488 + } 489 + 490 + cnt = dsk_get_block_cnt (dsk); 491 + buf_set_uint32_be (acsi->buf, 0, cnt - 1); 492 + buf_set_uint32_be (acsi->buf, 4, 512); 493 + 494 + acsi->buf_idx = 0; 495 + acsi->buf_cnt = 8; 496 + 497 + acsi->result = 0; 498 + } 499 + 500 + /* 501 + * CMD 1F: ICD 502 + */ 503 + static 504 + void st_acsi_cmd_1f (st_acsi_t *acsi) 505 + { 506 + switch (acsi->cmd[1]) { 507 + case 0x12: 508 + st_acsi_cmd_1f_12 (acsi); 509 + break; 510 + 511 + case 0x25: 512 + st_acsi_cmd_1f_25 (acsi); 513 + break; 514 + 515 + default: 516 + st_log_deb ("ACSI: CMD[%02X] UNKNOWN [%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X]\n", 517 + acsi->cmd[0], 518 + acsi->cmd[0], acsi->cmd[1], acsi->cmd[2], acsi->cmd[3], 519 + acsi->cmd[4], acsi->cmd[5], acsi->cmd[6], acsi->cmd[7], 520 + acsi->cmd[8], acsi->cmd[9], acsi->cmd[10] 521 + ); 522 + 523 + st_acsi_set_result (acsi, 0x20); 524 + } 525 + 526 + st_acsi_reset_cmd (acsi); 527 + } 528 + 445 529 static 446 530 void st_acsi_cmd (st_acsi_t *acsi) 447 531 { ··· 478 562 st_acsi_cmd_1a (acsi); 479 563 break; 480 564 565 + case 0x1f: 566 + st_acsi_cmd_1f (acsi); 567 + break; 568 + 481 569 default: 482 570 st_log_deb ("ACSI: CMD[%02X] UNKNOWN [%02X %02X %02X %02X %02X %02X]\n", 483 571 acsi->cmd[0], ··· 488 576 st_acsi_set_result (acsi, 0x20); 489 577 } 490 578 491 - acsi->cmd_cnt = 0; 579 + st_acsi_reset_cmd (acsi); 492 580 } 493 581 494 582 unsigned char st_acsi_get_data (st_acsi_t *acsi) ··· 549 637 st_log_deb ("ACSI: command byte %02X\n", val); 550 638 #endif 551 639 552 - if (acsi->cmd_cnt >= 6) { 553 - acsi->cmd_cnt = 0; 640 + if ((acsi->cmd_max > 0) && (acsi->cmd_cnt >= acsi->cmd_max)) { 641 + st_acsi_reset_cmd (acsi); 554 642 return; 555 643 } 556 644 ··· 561 649 #if DEBUG_ACSI >= 1 562 650 st_log_deb ("ACSI: ignoring command %02X\n", val); 563 651 #endif 564 - acsi->cmd_cnt = 0; 652 + st_acsi_reset_cmd (acsi); 565 653 return; 566 654 } 655 + 656 + if ((acsi->cmd[0] & 0x1f) != 0x1f) { 657 + acsi->cmd_max = 6; 658 + } 567 659 } 660 + else if ((acsi->cmd_cnt == 2) && ((acsi->cmd[0] & 0x1f) == 0x1f)) { 661 + switch (acsi->cmd[1] >> 5) { 662 + case 0: 663 + acsi->cmd_max = 6; 664 + break; 568 665 569 - if (acsi->cmd_cnt >= 6) { 666 + case 1: 667 + case 2: 668 + acsi->cmd_max = 10; 669 + break; 670 + 671 + default: 672 + acsi->cmd_max = 6; 673 + break; 674 + } 675 + 676 + acsi->cmd_max += 1; 677 + } 678 + 679 + if ((acsi->cmd_max > 0) && (acsi->cmd_cnt >= acsi->cmd_max)) { 570 680 acsi->blk = acsi->cmd[1]; 571 681 acsi->blk = (acsi->blk << 8) | acsi->cmd[2]; 572 682 acsi->blk = (acsi->blk << 8) | acsi->cmd[3]; ··· 584 694 void st_acsi_reset (st_acsi_t *acsi) 585 695 { 586 696 acsi->cmd_cnt = 0; 697 + acsi->cmd_max = 0; 587 698 588 699 acsi->buf_idx = 0; 589 700 acsi->buf_cnt = 0;
+3 -2
src/arch/atarist/acsi.h
··· 5 5 /***************************************************************************** 6 6 * File name: src/arch/atarist/acsi.h * 7 7 * Created: 2013-06-04 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2013 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2013-2014 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 31 31 32 32 typedef struct { 33 33 unsigned cmd_cnt; 34 - unsigned char cmd[8]; 34 + unsigned cmd_max; 35 + unsigned char cmd[16]; 35 36 36 37 unsigned char result; 37 38 unsigned char sense;