diff --git a/bochs/configure.in b/bochs/configure.in
index 8c88d4287..59a52b2ac 100644
--- a/bochs/configure.in
+++ b/bochs/configure.in
@@ -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
diff --git a/bochs/doc/docbook/user/user.dbk b/bochs/doc/docbook/user/user.dbk
index 27b716070..0d16890dd 100644
--- a/bochs/doc/docbook/user/user.dbk
+++ b/bochs/doc/docbook/user/user.dbk
@@ -2093,8 +2093,8 @@ to explicitly turn it off.
--enable-cdrom
yes
- 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
diff --git a/bochs/iodev/harddrv.cc b/bochs/iodev/harddrv.cc
index bc1f44b57..76c114cd0 100644
--- a/bochs/iodev/harddrv.cc
+++ b/bochs/iodev/harddrv.cc
@@ -125,9 +125,7 @@ bx_hard_drive_c::bx_hard_drive_c()
for (Bit8u channel=0; channelget_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);
diff --git a/bochs/iodev/harddrv.h b/bochs/iodev/harddrv.h
index 900807e11..fff9f5365 100644
--- a/bochs/iodev/harddrv.h
+++ b/bochs/iodev/harddrv.h
@@ -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;
diff --git a/bochs/iodev/hdimage/cdrom.cc b/bochs/iodev/hdimage/cdrom.cc
index 29b768093..39535deb3 100644
--- a/bochs/iodev/hdimage/cdrom.cc
+++ b/bochs/iodev/hdimage/cdrom.cc
@@ -27,8 +27,6 @@
#define BX_PLUGGABLE
#include "bochs.h"
-#if BX_SUPPORT_CDROM
-
#include "cdrom.h"
#include
@@ -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 */
diff --git a/bochs/iodev/hdimage/cdrom_amigaos.cc b/bochs/iodev/hdimage/cdrom_amigaos.cc
index f0119950b..816225887 100644
--- a/bochs/iodev/hdimage/cdrom_amigaos.cc
+++ b/bochs/iodev/hdimage/cdrom_amigaos.cc
@@ -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 */
diff --git a/bochs/iodev/hdimage/hdimage.cc b/bochs/iodev/hdimage/hdimage.cc
index 1fc5adb12..16df80613 100644
--- a/bochs/iodev/hdimage/hdimage.cc
+++ b/bochs/iodev/hdimage/hdimage.cc
@@ -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
diff --git a/bochs/iodev/hdimage/hdimage.h b/bochs/iodev/hdimage/hdimage.h
index 7d1552b91..eb0af8c74 100644
--- a/bochs/iodev/hdimage/hdimage.h
+++ b/bochs/iodev/hdimage/hdimage.h
@@ -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
diff --git a/bochs/iodev/iodev.h b/bochs/iodev/iodev.h
index dee41b176..8df5c9881 100644
--- a/bochs/iodev/iodev.h
+++ b/bochs/iodev/iodev.h
@@ -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
diff --git a/bochs/iodev/usb/scsi_device.cc b/bochs/iodev/usb/scsi_device.cc
index 3e5679cbb..65ce688e3 100644
--- a/bochs/iodev/usb/scsi_device.cc
+++ b/bochs/iodev/usb/scsi_device.cc
@@ -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);
}
diff --git a/bochs/iodev/usb/scsi_device.h b/bochs/iodev/usb/scsi_device.h
index 86c3a2c2f..5c52d1875 100644
--- a/bochs/iodev/usb/scsi_device.h
+++ b/bochs/iodev/usb/scsi_device.h
@@ -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;
diff --git a/bochs/iodev/usb/usb_msd.cc b/bochs/iodev/usb/usb_msd.cc
index 45e308e73..13ec53266 100644
--- a/bochs/iodev/usb/usb_msd.cc
+++ b/bochs/iodev/usb/usb_msd.cc
@@ -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()
diff --git a/bochs/iodev/usb/usb_msd.h b/bochs/iodev/usb/usb_msd.h
index 478b9a89f..9475118c7 100644
--- a/bochs/iodev/usb/usb_msd.h
+++ b/bochs/iodev/usb/usb_msd.h
@@ -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;