Always enable the portable ISO image file support. The option --enable-cdrom now

only controls the presence of platform-specific code to access CDROM/DVD devices
This commit is contained in:
Volker Ruppert 2013-11-10 11:14:42 +00:00
parent 3be7e5884b
commit 9554a2133e
13 changed files with 20 additions and 111 deletions

View File

@ -1688,9 +1688,9 @@ AC_ARG_ENABLE(cdrom,
[ bx_cdrom=1 ]
)
CDROM_OBJS='cdrom.o'
if test "$bx_cdrom" = 1; then
AC_MSG_RESULT(yes)
CDROM_OBJS='cdrom.o'
case $target in
*-pc-windows* | *-pc-winnt* | *-cygwin* | *-mingw32*)
CDROM_OBJS="$CDROM_OBJS cdrom_win32.o"
@ -1720,7 +1720,6 @@ if test "$bx_cdrom" = 1; then
esac
else
AC_MSG_RESULT(no)
CDROM_OBJS=''
AC_DEFINE(BX_SUPPORT_CDROM, 0)
fi

View File

@ -2093,8 +2093,8 @@ to explicitly turn it off.
<entry>--enable-cdrom</entry>
<entry>yes</entry>
<entry>
Enable use of a real CDROM. The cdrom emulation is always present, and
emulates a drive without media by default. You can use this option to
Enable use of a real CDROM/DVD drive. The cdrom emulation and the portable
ISO image file support are always present. You can use this option to
compile in support for accessing the media in your workstation's cdrom
drive. The supported platforms are Linux, Solaris, FreeBSD, OpenBSD,
MacOS X and Windows. For other platforms, a small amount of code specific

View File

@ -125,9 +125,7 @@ bx_hard_drive_c::bx_hard_drive_c()
for (Bit8u channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
for (Bit8u device=0; device<2; device ++) {
channels[channel].drives[device].hdimage = NULL;
#if BX_SUPPORT_CDROM
channels[channel].drives[device].cdrom.cd = NULL;
#endif
}
}
seek_timer_index = BX_NULL_TIMER_HANDLE;
@ -145,12 +143,10 @@ bx_hard_drive_c::~bx_hard_drive_c()
delete channels[channel].drives[device].hdimage;
channels[channel].drives[device].hdimage = NULL;
}
#if BX_SUPPORT_CDROM
if (channels[channel].drives[device].cdrom.cd != NULL) {
delete channels[channel].drives[device].cdrom.cd;
channels[channel].drives[device].cdrom.cd = NULL;
}
#endif
sprintf(ata_name, "ata.%d.%s", channel, (device==0)?"master":"slave");
base = (bx_list_c*) SIM->get_param(ata_name);
SIM->get_param_string("path", base)->set_handler(NULL);
@ -389,7 +385,6 @@ void bx_hard_drive_c::init(void)
BX_CONTROLLER(channel,device).sector_count = 0;
// allocate low level driver
#if BX_SUPPORT_CDROM
BX_HD_THIS channels[channel].drives[device].cdrom.cd = DEV_hdimage_init_cdrom(SIM->get_param_string("path", base)->getptr());
BX_INFO(("CD on ata%d-%d: '%s'",channel, device, SIM->get_param_string("path", base)->getptr()));
@ -405,10 +400,7 @@ void bx_hard_drive_c::init(void)
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0;
SIM->get_param_enum("status", base)->set(BX_EJECTED);
}
}
else
#endif
{
} else {
BX_INFO(("Media not present in CD-ROM drive"));
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0;
}
@ -863,7 +855,6 @@ Bit32u bx_hard_drive_c::read(Bit32u address, unsigned io_len)
case 0x28: // read (10)
case 0xa8: // read (12)
case 0xbe: // read cd
#if BX_SUPPORT_CDROM
if (!BX_SELECTED_DRIVE(channel).cdrom.ready) {
BX_PANIC(("Read with CDROM not ready"));
}
@ -886,9 +877,6 @@ Bit32u bx_hard_drive_c::read(Bit32u address, unsigned io_len)
}
// one block transfered, start at beginning
index = 0;
#else
BX_PANIC(("READ: lowlevel cdrom support disabled"));
#endif
break;
default: // no need to load a new block
@ -1270,9 +1258,7 @@ void bx_hard_drive_c::write(Bit32u address, Bit32u value, unsigned io_len)
atapi_cmd_nop(controller);
raise_interrupt(channel);
} else if (!LoEj && Start) { // start (spin up) the disc
#if BX_SUPPORT_CDROM
BX_SELECTED_DRIVE(channel).cdrom.cd->start_cdrom();
#endif
BX_ERROR(("FIXME: ATAPI start disc not reading TOC"));
atapi_cmd_nop(controller);
raise_interrupt(channel);
@ -1280,9 +1266,7 @@ void bx_hard_drive_c::write(Bit32u address, Bit32u value, unsigned io_len)
atapi_cmd_nop(controller);
if (BX_SELECTED_DRIVE(channel).cdrom.ready) {
#if BX_SUPPORT_CDROM
BX_SELECTED_DRIVE(channel).cdrom.cd->eject_cdrom();
#endif
BX_SELECTED_DRIVE(channel).cdrom.ready = 0;
sprintf(ata_name, "ata.%d.%s", channel, BX_SLAVE_SELECTED(channel)?"slave":"master");
bx_list_c *base = (bx_list_c*) SIM->get_param(ata_name);
@ -1589,17 +1573,14 @@ void bx_hard_drive_c::write(Bit32u address, Bit32u value, unsigned io_len)
case 0x43: // read toc
if (BX_SELECTED_DRIVE(channel).cdrom.ready) {
#if BX_SUPPORT_CDROM
bx_bool msf = (controller->buffer[1] >> 1) & 1;
Bit8u starting_track = controller->buffer[6];
int toc_length;
#endif
int toc_length = 0;
Bit16u alloc_length = read_16bit(controller->buffer + 7);
Bit8u format = (controller->buffer[9] >> 6);
// Win32: I just read the TOC using Win32's IOCTRL functions (Ben)
#if defined(WIN32)
#if BX_SUPPORT_CDROM
switch (format) {
// Win32: I just read the TOC using Win32's IOCTRL functions (Ben)
#if BX_SUPPORT_CDROM && defined(WIN32)
case 2:
case 3:
case 4:
@ -1617,20 +1598,10 @@ void bx_hard_drive_c::write(Bit32u address, Bit32u value, unsigned io_len)
ready_to_send_atapi(channel);
}
break;
default:
BX_ERROR(("(READ TOC) format %d not supported", format));
atapi_cmd_error(channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET, 1);
raise_interrupt(channel);
}
#else
BX_PANIC(("READ TOC: lowlevel cdrom support disabled"));
#endif
#else // WIN32
switch (format) {
case 0:
case 1:
case 2:
#if BX_SUPPORT_CDROM
if (!(BX_SELECTED_DRIVE(channel).cdrom.cd->read_toc(controller->buffer,
&toc_length, msf, starting_track, format))) {
atapi_cmd_error(channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET, 1);
@ -1639,18 +1610,13 @@ void bx_hard_drive_c::write(Bit32u address, Bit32u value, unsigned io_len)
init_send_atapi_command(channel, atapi_command, toc_length, alloc_length);
ready_to_send_atapi(channel);
}
#else
BX_PANIC(("READ TOC: lowlevel cdrom support disabled"));
#endif
break;
#endif
default:
BX_ERROR(("(READ TOC) format %d not supported", format));
atapi_cmd_error(channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET, 1);
raise_interrupt(channel);
break;
}
#endif // WIN32
} else {
atapi_cmd_error(channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT, 1);
raise_interrupt(channel);
@ -1728,11 +1694,7 @@ void bx_hard_drive_c::write(Bit32u address, Bit32u value, unsigned io_len)
raise_interrupt(channel);
break;
}
#if BX_SUPPORT_CDROM
BX_SELECTED_DRIVE(channel).cdrom.cd->seek(lba);
#else
BX_PANIC(("SEEK: lowlevel cdrom support disabled"));
#endif
atapi_cmd_nop(controller);
raise_interrupt(channel);
}
@ -3175,17 +3137,15 @@ bx_bool bx_hard_drive_c::set_cd_media_status(Bit32u handle, bx_bool status)
if (status == 0) {
// eject cdrom if not locked by guest OS
if (BX_HD_THIS channels[channel].drives[device].cdrom.locked) return(1);
else {
#if BX_SUPPORT_CDROM
if (!BX_HD_THIS channels[channel].drives[device].cdrom.locked) {
BX_HD_THIS channels[channel].drives[device].cdrom.cd->eject_cdrom();
#endif
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0;
SIM->get_param_enum("status", base)->set(BX_EJECTED);
} else {
return(1);
}
} else {
// insert cdrom
#if BX_SUPPORT_CDROM
if (BX_HD_THIS channels[channel].drives[device].cdrom.cd->insert_cdrom(SIM->get_param_string("path", base)->getptr())) {
BX_INFO(("Media present in CD-ROM drive"));
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 1;
@ -3197,10 +3157,7 @@ bx_bool bx_hard_drive_c::set_cd_media_status(Bit32u handle, bx_bool status)
BX_SELECTED_DRIVE(channel).sense.asc = ASC_MEDIUM_MAY_HAVE_CHANGED;
BX_SELECTED_DRIVE(channel).sense.ascq = 0;
raise_interrupt(channel);
}
else
#endif
{
} else {
BX_INFO(("Could not locate CD-ROM, continuing with media not present"));
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0;
SIM->get_param_enum("status", base)->set(BX_EJECTED);
@ -3243,7 +3200,6 @@ bx_bool bx_hard_drive_c::bmdma_read_sector(Bit8u channel, Bit8u *buffer, Bit32u
}
/* set status bar conditions for device */
bx_gui->statusbar_setitem(BX_SELECTED_DRIVE(channel).statusbar_id, 1);
#if BX_SUPPORT_CDROM
if (!BX_SELECTED_DRIVE(channel).cdrom.cd->read_block(buffer, BX_SELECTED_DRIVE(channel).cdrom.next_lba,
controller->buffer_size))
{
@ -3252,9 +3208,6 @@ bx_bool bx_hard_drive_c::bmdma_read_sector(Bit8u channel, Bit8u *buffer, Bit32u
}
BX_SELECTED_DRIVE(channel).cdrom.next_lba++;
BX_SELECTED_DRIVE(channel).cdrom.remaining_blocks--;
#else
BX_PANIC(("BM-DMA read with lowlevel cdrom support disabled"));
#endif
break;
default:
memcpy(buffer, controller->buffer, *sector_size);

View File

@ -38,9 +38,7 @@ typedef enum _asc {
} asc_t;
class device_image_t;
#if BX_SUPPORT_CDROM
class cdrom_base_c;
#endif
typedef struct {
struct {
@ -134,9 +132,7 @@ struct cdrom_t
{
bx_bool ready;
bx_bool locked;
#if BX_SUPPORT_CDROM
cdrom_base_c *cd;
#endif
Bit32u capacity;
int next_lba;
int remaining_blocks;

View File

@ -27,8 +27,6 @@
#define BX_PLUGGABLE
#include "bochs.h"
#if BX_SUPPORT_CDROM
#include "cdrom.h"
#include <stdio.h>
@ -305,5 +303,3 @@ bx_bool cdrom_base_c::seek(Bit32u lba)
return read_block(buffer, lba, BX_CD_FRAMESIZE);
}
#endif /* if BX_SUPPORT_CDROM */

View File

@ -27,6 +27,8 @@
#include "bochs.h"
#if BX_SUPPORT_CDROM
#include "scsi_commands.h"
#include "cdrom.h"
#include "cdrom_amigaos.h"
@ -349,3 +351,5 @@ int DoSCSI(UBYTE *data, int datasize, Bit8u *cmd,int cmdsize, UBYTE direction)
return CDIO->iotd_Req.io_Error;
}
#endif /* if BX_SUPPORT_CDROM */

View File

@ -144,12 +144,14 @@ device_image_t* bx_hdimage_ctl_c::init_image(Bit8u image_mode, Bit64u disk_size,
return hdimage;
}
#if BX_SUPPORT_CDROM
cdrom_base_c* bx_hdimage_ctl_c::init_cdrom(const char *dev)
{
#if BX_SUPPORT_CDROM
return new LOWLEVEL_CDROM(dev);
}
#else
return new cdrom_base_c(dev);
#endif
}
#endif // ifndef BXIMAGE

View File

@ -588,9 +588,7 @@ public:
bx_hdimage_ctl_c();
virtual ~bx_hdimage_ctl_c() {}
virtual device_image_t *init_image(Bit8u image_mode, Bit64u disk_size, const char *journal);
#if BX_SUPPORT_CDROM
virtual cdrom_base_c *init_cdrom(const char *dev);
#endif
};
#endif // BXIMAGE

View File

@ -338,11 +338,9 @@ public:
virtual device_image_t* init_image(Bit8u image_mode, Bit64u disk_size, const char *journal) {
STUBFUNC(hdimage_ctl, init_image); return NULL;
}
#if BX_SUPPORT_CDROM
virtual cdrom_base_c* init_cdrom(const char *dev) {
STUBFUNC(hdimage_ctl, init_cdrom); return NULL;
}
#endif
};
#if BX_SUPPORT_SOUNDLOW

View File

@ -49,9 +49,7 @@ scsi_device_t::scsi_device_t(device_image_t *_hdimage, int _tcq,
scsi_completionfn _completion, void *_dev)
{
type = SCSIDEV_TYPE_DISK;
#if BX_SUPPORT_CDROM
cdrom = NULL;
#endif
hdimage = _hdimage;
requests = NULL;
sense = 0;
@ -67,7 +65,6 @@ scsi_device_t::scsi_device_t(device_image_t *_hdimage, int _tcq,
put("SCSID");
}
#if BX_SUPPORT_CDROM
scsi_device_t::scsi_device_t(cdrom_base_c *_cdrom, int _tcq,
scsi_completionfn _completion, void *_dev)
{
@ -87,7 +84,6 @@ scsi_device_t::scsi_device_t(cdrom_base_c *_cdrom, int _tcq,
put("SCSIC");
}
#endif
scsi_device_t::~scsi_device_t(void)
{
@ -239,15 +235,11 @@ void scsi_device_t::scsi_read_data(Bit32u tag)
n = SCSI_DMA_BUF_SIZE / (512 * cluster_size);
r->buf_len = n * 512 * cluster_size;
if (type == SCSIDEV_TYPE_CDROM) {
#if BX_SUPPORT_CDROM
if (!cdrom->read_block(r->dma_buf, (Bit32u)r->sector, 2048)) {
scsi_command_complete(r, STATUS_CHECK_CONDITION, SENSE_HARDWARE_ERROR);
} else {
scsi_read_complete((void*)r, 0);
}
#else
scsi_command_complete(r, STATUS_CHECK_CONDITION, SENSE_HARDWARE_ERROR);
#endif
} else {
ret = (int)hdimage->lseek(r->sector * 512, SEEK_SET);
if (ret < 0) {
@ -637,9 +629,7 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
if (type == SCSIDEV_TYPE_CDROM && (buf[4] & 2)) {
if (!(buf[4] & 1)) {
// eject medium
#if BX_SUPPORT_CDROM
cdrom->eject_cdrom();
#endif
inserted = 0;
}
}
@ -653,11 +643,7 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
// The normal LEN field for this command is zero
memset(outbuf, 0, 8);
if (type == SCSIDEV_TYPE_CDROM) {
#if BX_SUPPORT_CDROM
nb_sectors = cdrom->capacity();
#else
nb_sectors = 0;
#endif
} else {
nb_sectors = hdimage->hd_size / 512;
}
@ -711,9 +697,7 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
format = buf[2] & 0xf;
start_track = buf[6];
BX_DEBUG(("Read TOC (track %d format %d msf %d)", start_track, format, msf >> 1));
#if BX_SUPPORT_CDROM
cdrom->read_toc(outbuf, &toclen, msf, start_track, format);
#endif
if (toclen > 0) {
if (len > toclen)
len = toclen;
@ -770,11 +754,7 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
// Current/Max Cap Header
if (type == SCSIDEV_TYPE_CDROM) {
#if BX_SUPPORT_CDROM
nb_sectors = cdrom->capacity();
#else
nb_sectors = 0;
#endif
} else {
nb_sectors = (hdimage->hd_size / 512);
}

View File

@ -70,10 +70,8 @@ class scsi_device_t : public logfunctions {
public:
scsi_device_t(device_image_t *_hdimage, int _tcq,
scsi_completionfn _completion, void *_dev);
#if BX_SUPPORT_CDROM
scsi_device_t(cdrom_base_c *_cdrom, int _tcq,
scsi_completionfn _completion, void *_dev);
#endif
virtual ~scsi_device_t(void);
void register_state(bx_list_c *parent, const char *name);
@ -97,9 +95,7 @@ protected:
private:
enum scsidev_type type;
device_image_t *hdimage;
#if BX_SUPPORT_CDROM
cdrom_base_c *cdrom;
#endif
SCSIRequest *requests;
int cluster_size;
Bit64u max_lba;

View File

@ -202,7 +202,6 @@ usb_msd_device_c::~usb_msd_device_c(void)
delete s.scsi_dev;
if (s.hdimage != NULL) {
delete s.hdimage;
#if BX_SUPPORT_CDROM
} else if (s.cdrom != NULL) {
delete s.cdrom;
#if BX_WITH_WX
@ -211,7 +210,6 @@ usb_msd_device_c::~usb_msd_device_c(void)
#endif
bx_list_c *usb_rt = (bx_list_c*)SIM->get_param(BXPN_MENU_RUNTIME_USB);
usb_rt->remove(s.config->get_name());
#endif
}
}
@ -236,7 +234,6 @@ bx_bool usb_msd_device_c::init()
}
sprintf(s.info_txt, "USB HD: path='%s', mode='%s'", s.fname, hdimage_mode_names[s.image_mode]);
} else if (d.type == USB_DEV_TYPE_CDROM) {
#if BX_SUPPORT_CDROM
s.cdrom = DEV_hdimage_init_cdrom(s.fname);
if (!s.cdrom->insert_cdrom()) {
BX_ERROR(("could not open cdrom image file '%s'", s.fname));
@ -245,10 +242,6 @@ bx_bool usb_msd_device_c::init()
s.scsi_dev = new scsi_device_t(s.cdrom, 0, usb_msd_command_complete, (void*)this);
}
sprintf(s.info_txt, "USB CD: path='%s'", s.fname);
#else
BX_PANIC(("missing lowlevel cdrom support"));
return 0;
#endif
}
s.scsi_dev->register_state(s.sr_list, "scsidev");
s.mode = USB_MSDM_CBW;
@ -661,7 +654,6 @@ void usb_msd_device_c::cancel_packet(USBPacket *p)
void usb_msd_device_c::set_inserted(bx_bool value)
{
#if BX_SUPPORT_CDROM
const char *path;
if (value) {
@ -674,9 +666,6 @@ void usb_msd_device_c::set_inserted(bx_bool value)
s.cdrom->eject_cdrom();
}
s.scsi_dev->set_inserted(value);
#else
SIM->get_param_bool("status", s.config)->set(0);
#endif
}
bx_bool usb_msd_device_c::get_inserted()

View File

@ -66,9 +66,7 @@ private:
int result;
Bit8u image_mode;
device_image_t *hdimage;
#if BX_SUPPORT_CDROM
cdrom_base_c *cdrom;
#endif
scsi_device_t *scsi_dev;
USBPacket *packet;
bx_list_c *sr_list;