25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: diskimage.c,v 1.95 2005/08/10 22:25:50 debug Exp $ |
* $Id: diskimage.c,v 1.98 2005/09/27 23:55:43 debug Exp $ |
29 |
* |
* |
30 |
* Disk image support. |
* Disk image support. |
31 |
* |
* |
478 |
int diskimage_scsicommand(struct cpu *cpu, int id, int type, |
int diskimage_scsicommand(struct cpu *cpu, int id, int type, |
479 |
struct scsi_transfer *xferp) |
struct scsi_transfer *xferp) |
480 |
{ |
{ |
481 |
|
char namebuf[16]; |
482 |
int retlen, i; |
int retlen, i; |
483 |
uint64_t size; |
uint64_t size; |
484 |
int64_t ofs; |
int64_t ofs; |
589 |
xferp->data_in[6] = 0x04; /* ACKREQQ */ |
xferp->data_in[6] = 0x04; /* ACKREQQ */ |
590 |
xferp->data_in[7] = 0x60; /* WBus32, WBus16 */ |
xferp->data_in[7] = 0x60; /* WBus32, WBus16 */ |
591 |
|
|
592 |
/* These must be padded with spaces: */ |
/* These are padded with spaces: */ |
593 |
memcpy(xferp->data_in+8, "FAKE ", 8); |
|
594 |
memcpy(xferp->data_in+16, "DISK ", 16); |
memcpy(xferp->data_in+8, "EMULATED", 8); |
595 |
memcpy(xferp->data_in+32, "V0.0", 4); |
if (diskimage_getname(cpu->machine, id, |
596 |
|
type, namebuf, sizeof(namebuf))) { |
597 |
|
int i; |
598 |
|
for (i=0; i<sizeof(namebuf); i++) |
599 |
|
if (namebuf[i] == 0) { |
600 |
|
for (; i<sizeof(namebuf); i++) |
601 |
|
namebuf[i] = ' '; |
602 |
|
break; |
603 |
|
} |
604 |
|
memcpy(xferp->data_in+16, namebuf, 16); |
605 |
|
} else |
606 |
|
memcpy(xferp->data_in+16, "DISK ", 16); |
607 |
|
memcpy(xferp->data_in+32, "0000", 4); |
608 |
|
|
609 |
/* |
/* |
610 |
* Some Ultrix kernels want specific responses from |
* Some Ultrix kernels want specific responses from |
1490 |
machine->machine_type == MACHINE_COBALT || |
machine->machine_type == MACHINE_COBALT || |
1491 |
machine->machine_type == MACHINE_EVBMIPS || |
machine->machine_type == MACHINE_EVBMIPS || |
1492 |
machine->machine_type == MACHINE_HPCMIPS || |
machine->machine_type == MACHINE_HPCMIPS || |
1493 |
|
machine->machine_type == MACHINE_CATS || |
1494 |
|
machine->machine_type == MACHINE_NETWINDER || |
1495 |
machine->machine_type == MACHINE_PS2) |
machine->machine_type == MACHINE_PS2) |
1496 |
d->type = DISKIMAGE_IDE; |
d->type = DISKIMAGE_IDE; |
1497 |
|
|
1520 |
* Is this a tape, CD-ROM or a normal disk? |
* Is this a tape, CD-ROM or a normal disk? |
1521 |
* |
* |
1522 |
* An intelligent guess, if no prefixes are used, would be that |
* An intelligent guess, if no prefixes are used, would be that |
1523 |
* filenames ending with .iso are CD-ROM images. |
* filenames ending with .iso or .cdr are CD-ROM images. |
1524 |
*/ |
*/ |
1525 |
if (prefix_t) { |
if (prefix_t) { |
1526 |
d->is_a_tape = 1; |
d->is_a_tape = 1; |
1527 |
} else { |
} else { |
1528 |
if (prefix_c || |
if (prefix_c || |
1529 |
((strlen(d->fname) > 4 && |
((strlen(d->fname) > 4 && |
1530 |
strcasecmp(d->fname + strlen(d->fname) - 4, ".iso") == 0) |
(strcasecmp(d->fname + strlen(d->fname) - 4, ".cdr") == 0 || |
1531 |
|
strcasecmp(d->fname + strlen(d->fname) - 4, ".iso") == 0)) |
1532 |
&& !prefix_d) |
&& !prefix_d) |
1533 |
) { |
) { |
1534 |
d->is_a_cdrom = 1; |
d->is_a_cdrom = 1; |
1685 |
} |
} |
1686 |
|
|
1687 |
|
|
1688 |
|
/* |
1689 |
|
* diskimage_getname(): |
1690 |
|
* |
1691 |
|
* Returns 1 if a valid disk image name was returned, 0 otherwise. |
1692 |
|
*/ |
1693 |
|
int diskimage_getname(struct machine *machine, int id, int type, |
1694 |
|
char *buf, size_t bufsize) |
1695 |
|
{ |
1696 |
|
struct diskimage *d = machine->first_diskimage; |
1697 |
|
|
1698 |
|
if (buf == NULL) |
1699 |
|
return 0; |
1700 |
|
|
1701 |
|
while (d != NULL) { |
1702 |
|
if (d->type == type && d->id == id) { |
1703 |
|
char *p = strrchr(d->fname, '/'); |
1704 |
|
if (p == NULL) |
1705 |
|
p = d->fname; |
1706 |
|
else |
1707 |
|
p ++; |
1708 |
|
snprintf(buf, bufsize, "%s", p); |
1709 |
|
return 1; |
1710 |
|
} |
1711 |
|
d = d->next; |
1712 |
|
} |
1713 |
|
return 0; |
1714 |
|
} |
1715 |
|
|
1716 |
|
|
1717 |
/* |
/* |
1718 |
* diskimage_is_a_cdrom(): |
* diskimage_is_a_cdrom(): |
1719 |
* |
* |