1 |
/* |
/* |
2 |
* Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: diskimage.c,v 1.102 2005/11/21 09:17:25 debug Exp $ |
* $Id: diskimage.c,v 1.111 2006/08/14 17:27:45 debug Exp $ |
29 |
* |
* |
30 |
* Disk image support. |
* Disk image support. |
31 |
* |
* |
451 |
|
|
452 |
/* Warn about non-complete data transfers: */ |
/* Warn about non-complete data transfers: */ |
453 |
if (lendone != (ssize_t)len) { |
if (lendone != (ssize_t)len) { |
454 |
|
#ifdef UNSTABLE_DEVEL |
455 |
fatal("[ diskimage__internal_access(): disk_id %i, offset %lli" |
fatal("[ diskimage__internal_access(): disk_id %i, offset %lli" |
456 |
", transfer not completed. len=%i, len_done=%i ]\n", |
", transfer not completed. len=%i, len_done=%i ]\n", |
457 |
d->id, (long long)offset, (int)len, (int)lendone); |
d->id, (long long)offset, (int)len, (int)lendone); |
458 |
|
#endif |
459 |
return 0; |
return 0; |
460 |
} |
} |
461 |
|
|
526 |
fatal(" %02x", xferp->cmd[i]); |
fatal(" %02x", xferp->cmd[i]); |
527 |
fatal("\n"); |
fatal("\n"); |
528 |
if (xferp->cmd_len > 7 && xferp->cmd[5] == 0x11) |
if (xferp->cmd_len > 7 && xferp->cmd[5] == 0x11) |
529 |
single_step = 1; |
single_step = ENTER_SINGLE_STEPPING; |
530 |
#endif |
#endif |
531 |
|
|
532 |
#if 0 |
#if 0 |
597 |
memcpy(xferp->data_in+8, "GXemul ", 8); |
memcpy(xferp->data_in+8, "GXemul ", 8); |
598 |
if (diskimage_getname(cpu->machine, id, |
if (diskimage_getname(cpu->machine, id, |
599 |
type, namebuf, sizeof(namebuf))) { |
type, namebuf, sizeof(namebuf))) { |
600 |
int i; |
size_t i; |
601 |
for (i=0; i<sizeof(namebuf); i++) |
for (i=0; i<sizeof(namebuf); i++) |
602 |
if (namebuf[i] == 0) { |
if (namebuf[i] == 0) { |
603 |
for (; i<sizeof(namebuf); i++) |
for (; i<sizeof(namebuf); i++) |
614 |
* the drives. |
* the drives. |
615 |
*/ |
*/ |
616 |
|
|
617 |
if (machine->machine_type == MACHINE_DEC) { |
if (machine->machine_type == MACHINE_PMAX) { |
618 |
/* DEC, RZ25 (rev 0900) = 832527 sectors */ |
/* DEC, RZ25 (rev 0900) = 832527 sectors */ |
619 |
/* DEC, RZ58 (rev 2000) = 2698061 sectors */ |
/* DEC, RZ58 (rev 2000) = 2698061 sectors */ |
620 |
memcpy(xferp->data_in+8, "DEC ", 8); |
memcpy(xferp->data_in+8, "DEC ", 8); |
628 |
xferp->data_in[1] = 0x80; /* 0x80 = removable */ |
xferp->data_in[1] = 0x80; /* 0x80 = removable */ |
629 |
/* memcpy(xferp->data_in+16, "CD-ROM ", 16);*/ |
/* memcpy(xferp->data_in+16, "CD-ROM ", 16);*/ |
630 |
|
|
631 |
if (machine->machine_type == MACHINE_DEC) { |
if (machine->machine_type == MACHINE_PMAX) { |
632 |
/* SONY, CD-ROM: */ |
/* SONY, CD-ROM: */ |
633 |
memcpy(xferp->data_in+8, "SONY ", 8); |
memcpy(xferp->data_in+8, "SONY ", 8); |
634 |
memcpy(xferp->data_in+16, |
memcpy(xferp->data_in+16, |
654 |
xferp->data_in[1] = 0x80; /* 0x80 = removable */ |
xferp->data_in[1] = 0x80; /* 0x80 = removable */ |
655 |
memcpy(xferp->data_in+16, "TAPE ", 16); |
memcpy(xferp->data_in+16, "TAPE ", 16); |
656 |
|
|
657 |
if (machine->machine_type == MACHINE_DEC) { |
if (machine->machine_type == MACHINE_PMAX) { |
658 |
/* |
/* |
659 |
* TODO: find out if these are correct. |
* TODO: find out if these are correct. |
660 |
* |
* |
899 |
* blocks to transfer. (NOTE: If the value is |
* blocks to transfer. (NOTE: If the value is |
900 |
* 0, this means 0, not 65536. :-) |
* 0, this means 0, not 65536. :-) |
901 |
*/ |
*/ |
902 |
ofs = (xferp->cmd[2] << 24) + (xferp->cmd[3] |
ofs = ((uint64_t)xferp->cmd[2] << 24) + |
903 |
<< 16) + (xferp->cmd[4] << 8) + |
(xferp->cmd[3] << 16) + (xferp->cmd[4] << 8) |
904 |
xferp->cmd[5]; |
+ xferp->cmd[5]; |
905 |
retlen = (xferp->cmd[7] << 8) + xferp->cmd[8]; |
retlen = (xferp->cmd[7] << 8) + xferp->cmd[8]; |
906 |
} |
} |
907 |
|
|
977 |
* transfer. (NOTE: If the value is 0 this means 0, |
* transfer. (NOTE: If the value is 0 this means 0, |
978 |
* not 65536.) |
* not 65536.) |
979 |
*/ |
*/ |
980 |
ofs = (xferp->cmd[2] << 24) + (xferp->cmd[3] << 16) + |
ofs = ((uint64_t)xferp->cmd[2] << 24) + |
981 |
(xferp->cmd[4] << 8) + xferp->cmd[5]; |
(xferp->cmd[3] << 16) + (xferp->cmd[4] << 8) + |
982 |
|
xferp->cmd[5]; |
983 |
retlen = (xferp->cmd[7] << 8) + xferp->cmd[8]; |
retlen = (xferp->cmd[7] << 8) + xferp->cmd[8]; |
984 |
} |
} |
985 |
|
|
1027 |
if (xferp->cmd_len != 6) |
if (xferp->cmd_len != 6) |
1028 |
debug(" (weird len=%i)", xferp->cmd_len); |
debug(" (weird len=%i)", xferp->cmd_len); |
1029 |
|
|
1030 |
for (i=0; i<xferp->cmd_len; i++) |
for (i=0; i<(ssize_t)xferp->cmd_len; i++) |
1031 |
debug(" %02x", xferp->cmd[i]); |
debug(" %02x", xferp->cmd[i]); |
1032 |
|
|
1033 |
/* TODO: actualy care about cmd[] */ |
/* TODO: actualy care about cmd[] */ |
1288 |
} else { |
} else { |
1289 |
int i; |
int i; |
1290 |
fatal("[ unknown MODE_SELECT: cmd ="); |
fatal("[ unknown MODE_SELECT: cmd ="); |
1291 |
for (i=0; i<xferp->cmd_len; i++) |
for (i=0; i<(ssize_t)xferp->cmd_len; i++) |
1292 |
fatal(" %02x", xferp->cmd[i]); |
fatal(" %02x", xferp->cmd[i]); |
1293 |
fatal(", data_out ="); |
fatal(", data_out ="); |
1294 |
for (i=0; i<xferp->data_out_len; i++) |
for (i=0; i<(ssize_t)xferp->data_out_len; i++) |
1295 |
fatal(" %02x", xferp->data_out[i]); |
fatal(" %02x", xferp->data_out[i]); |
1296 |
fatal(" ]"); |
fatal(" ]"); |
1297 |
} |
} |
1310 |
case 0xbd: |
case 0xbd: |
1311 |
fatal("[ SCSI 0x%02x (len %i), TODO: ", xferp->cmd[0], |
fatal("[ SCSI 0x%02x (len %i), TODO: ", xferp->cmd[0], |
1312 |
xferp->cmd_len); |
xferp->cmd_len); |
1313 |
for (i=0; i<xferp->cmd_len; i++) |
for (i=0; i<(ssize_t)xferp->cmd_len; i++) |
1314 |
fatal(" %02x", xferp->cmd[i]); |
fatal(" %02x", xferp->cmd[i]); |
1315 |
fatal(" ]\n"); |
fatal(" ]\n"); |
1316 |
|
|
1501 |
d2->next = d; |
d2->next = d; |
1502 |
} |
} |
1503 |
|
|
1504 |
d->type = DISKIMAGE_SCSI; |
/* Default to IDE disks... */ |
1505 |
|
d->type = DISKIMAGE_IDE; |
1506 |
|
|
1507 |
/* Special cases: some machines usually have FLOPPY/IDE, not SCSI: */ |
/* ... but some machines use SCSI by default: */ |
1508 |
if (machine->arch == ARCH_X86 || |
if (machine->machine_type == MACHINE_PMAX || |
1509 |
machine->machine_type == MACHINE_COBALT || |
machine->machine_type == MACHINE_ARC) |
1510 |
machine->machine_type == MACHINE_EVBMIPS || |
d->type = DISKIMAGE_SCSI; |
|
machine->machine_type == MACHINE_HPCMIPS || |
|
|
machine->machine_type == MACHINE_BEBOX || |
|
|
machine->machine_type == MACHINE_PREP || |
|
|
machine->machine_type == MACHINE_CATS || |
|
|
machine->machine_type == MACHINE_NETWINDER || |
|
|
machine->machine_type == MACHINE_PS2) |
|
|
d->type = DISKIMAGE_IDE; |
|
1511 |
|
|
1512 |
if (prefix_i + prefix_f + prefix_s > 1) { |
if (prefix_i + prefix_f + prefix_s > 1) { |
1513 |
fprintf(stderr, "Invalid disk image prefix(es). You can" |
fprintf(stderr, "Invalid disk image prefix(es). You can" |
1560 |
*/ |
*/ |
1561 |
|
|
1562 |
#if 0 |
#if 0 |
1563 |
if (machine->machine_type == MACHINE_DEC) |
if (machine->machine_type == MACHINE_PMAX) |
1564 |
d->logical_block_size = 512; |
d->logical_block_size = 512; |
1565 |
else |
else |
1566 |
d->logical_block_size = 2048; |
d->logical_block_size = 2048; |
1774 |
*/ |
*/ |
1775 |
void diskimage_dump_info(struct machine *machine) |
void diskimage_dump_info(struct machine *machine) |
1776 |
{ |
{ |
1777 |
int iadd=4; |
int iadd = DEBUG_INDENTATION; |
1778 |
struct diskimage *d = machine->first_diskimage; |
struct diskimage *d = machine->first_diskimage; |
1779 |
|
|
1780 |
while (d != NULL) { |
while (d != NULL) { |