- link lowlevel cdrom support with the hdimage plugin instead of harddrv and usb_common. This fixes

duplicate log prefixes on Windows if both IDE and USB cdroms are used in plugin mode. Windows also
  requires the cdrom base class and the init_cdrom() method to link and work correctly.
This commit is contained in:
Volker Ruppert 2011-07-17 17:23:12 +00:00
parent b44d756943
commit 5014eed268
9 changed files with 56 additions and 38 deletions

View File

@ -137,11 +137,8 @@ libbx_%.la: %.lo
$(LIBTOOL) --mode=link $(CXX) -module $< -o $@ -rpath $(PLUGIN_PATH)
# special link rules for plugins that require more than one object file
libbx_harddrv.la: harddrv.lo $(CDROM_OBJS:.o=.lo)
$(LIBTOOL) --mode=link $(CXX) -module harddrv.lo $(CDROM_OBJS:.o=.lo) -o libbx_harddrv.la -rpath $(PLUGIN_PATH)
libbx_hdimage.la: hdimage.lo vmware3.lo vmware4.lo vvfat.lo
$(LIBTOOL) --mode=link $(CXX) -module hdimage.lo vmware3.lo vmware4.lo vvfat.lo -o libbx_hdimage.la -rpath $(PLUGIN_PATH)
libbx_hdimage.la: hdimage.lo vmware3.lo vmware4.lo vvfat.lo $(CDROM_OBJS:.o=.lo)
$(LIBTOOL) --mode=link $(CXX) -module hdimage.lo vmware3.lo vmware4.lo vvfat.lo $(CDROM_OBJS:.o=.lo) -o libbx_hdimage.la -rpath $(PLUGIN_PATH)
libbx_keyboard.la: keyboard.lo scancodes.lo
$(LIBTOOL) --mode=link $(CXX) -module keyboard.lo scancodes.lo -o libbx_keyboard.la -rpath $(PLUGIN_PATH)
@ -164,19 +161,16 @@ libbx_serial.la: serial.lo serial_raw.lo
libbx_vga.la: vga.lo svga_cirrus.lo
$(LIBTOOL) --mode=link $(CXX) -module vga.lo svga_cirrus.lo -o libbx_vga.la -rpath $(PLUGIN_PATH)
libbx_usb_common.la: usb_common.lo $(USBDEV_OBJS:.o=.lo) scsi_device.lo $(CDROM_OBJS:.o=.lo)
$(LIBTOOL) --mode=link $(CXX) -module usb_common.lo $(USBDEV_OBJS:.o=.lo) scsi_device.lo $(CDROM_OBJS:.o=.lo) -o libbx_usb_common.la -rpath $(PLUGIN_PATH)
libbx_usb_common.la: usb_common.lo $(USBDEV_OBJS:.o=.lo) scsi_device.lo
$(LIBTOOL) --mode=link $(CXX) -module usb_common.lo $(USBDEV_OBJS:.o=.lo) scsi_device.lo -o libbx_usb_common.la -rpath $(PLUGIN_PATH)
#### building DLLs for win32 (tested on cygwin only)
bx_%.dll: %.o
$(CXX) $(CXXFLAGS) -shared -o $@ $< $(WIN32_DLL_IMPORT_LIBRARY)
# special link rules for plugins that require more than one object file
bx_harddrv.dll: harddrv.o $(CDROM_OBJS)
$(CXX) $(CXXFLAGS) -shared -o bx_harddrv.dll harddrv.o $(CDROM_OBJS) $(WIN32_DLL_IMPORT_LIBRARY)
bx_hdimage.dll: hdimage.o vmware3.o vmware4.o vvfat.o
$(CXX) $(CXXFLAGS) -shared -o bx_hdimage.dll hdimage.o vmware3.o vmware4.o vvfat.o $(WIN32_DLL_IMPORT_LIBRARY)
bx_hdimage.dll: hdimage.o vmware3.o vmware4.o vvfat.o $(CDROM_OBJS)
$(CXX) $(CXXFLAGS) -shared -o bx_hdimage.dll hdimage.o vmware3.o vmware4.o vvfat.o $(CDROM_OBJS) $(WIN32_DLL_IMPORT_LIBRARY)
bx_keyboard.dll: keyboard.o scancodes.o
$(CXX) $(CXXFLAGS) -shared -o bx_keyboard.dll keyboard.o scancodes.o $(WIN32_DLL_IMPORT_LIBRARY)
@ -202,8 +196,8 @@ bx_serial.dll: serial.o serial_raw.o
bx_vga.dll: vga.o svga_cirrus.o
$(CXX) $(CXXFLAGS) -shared -o bx_vga.dll vga.o svga_cirrus.o $(WIN32_DLL_IMPORT_LIBRARY)
bx_usb_common.dll: usb_common.o $(USBDEV_OBJS) scsi_device.o $(CDROM_OBJS)
$(CXX) $(CXXFLAGS) -shared -o bx_usb_common.dll usb_common.o $(USBDEV_OBJS) scsi_device.o $(CDROM_OBJS) $(WIN32_DLL_IMPORT_LIBRARY)
bx_usb_common.dll: usb_common.o $(USBDEV_OBJS) scsi_device.o
$(CXX) $(CXXFLAGS) -shared -o bx_usb_common.dll usb_common.o $(USBDEV_OBJS) scsi_device.o $(WIN32_DLL_IMPORT_LIBRARY)
##### end DLL section

View File

@ -514,12 +514,6 @@ cdrom_interface::cdrom_interface(const char *dev)
#endif
}
void cdrom_interface::init(void)
{
BX_DEBUG(("Init $Id$"));
BX_INFO(("file = '%s'",path));
}
cdrom_interface::~cdrom_interface(void)
{
#ifndef WIN32

View File

@ -22,31 +22,43 @@
// Header file for low-level OS specific CDROM emulation
class cdrom_interface : public logfunctions {
class cdrom_base_c : public logfunctions {
public:
virtual ~cdrom_base_c(void) {}
// Load CD-ROM. Returns 0 if CD is not ready.
virtual bx_bool insert_cdrom(const char *dev = NULL) = 0;
// Logically eject the CD.
virtual void eject_cdrom() = 0;
// Read CD TOC. Returns 0 if start track is out of bounds.
virtual bx_bool read_toc(Bit8u* buf, int* length, bx_bool msf, int start_track, int format) = 0;
// Return CD-ROM capacity (in 2048 byte frames)
virtual Bit32u capacity() = 0;
// Read a single block from the CD. Returns 0 on failure.
virtual bx_bool read_block(Bit8u* buf, Bit32u lba, int blocksize) BX_CPP_AttrRegparmN(3) = 0;
// Start (spin up) the CD.
virtual bx_bool start_cdrom() = 0;
// Seek for new block address.
virtual void seek(Bit32u lba) = 0;
};
class cdrom_interface : public cdrom_base_c {
public:
cdrom_interface(const char *dev);
virtual ~cdrom_interface(void);
void init(void);
// Load CD-ROM. Returns 0 if CD is not ready.
bx_bool insert_cdrom(const char *dev = NULL);
// Logically eject the CD.
void eject_cdrom();
// Read CD TOC. Returns 0 if start track is out of bounds.
bx_bool read_toc(Bit8u* buf, int* length, bx_bool msf, int start_track, int format);
// Return CD-ROM capacity (in 2048 byte frames)
Bit32u capacity();
// Read a single block from the CD. Returns 0 on failure.
bx_bool read_block(Bit8u* buf, Bit32u lba, int blocksize) BX_CPP_AttrRegparmN(3);
// Start (spin up) the CD.
bx_bool start_cdrom();
// Seek for new block address.
void seek(Bit32u lba);
private:
@ -61,5 +73,5 @@ private:
int tid;
int lun;
#endif
};
};

View File

@ -397,7 +397,7 @@ void bx_hard_drive_c::init(void)
// allocate low level driver
#ifdef LOWLEVEL_CDROM
BX_HD_THIS channels[channel].drives[device].cdrom.cd = new LOWLEVEL_CDROM(SIM->get_param_string("path", base)->getptr());
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()));
if (SIM->get_param_bool("status", base)->get()) {

View File

@ -25,6 +25,7 @@
#define BX_PLUGGABLE
#include "iodev.h"
#include "cdrom.h"
#include "hdimage.h"
#include "vmware3.h"
#include "vmware4.h"
@ -133,6 +134,13 @@ device_image_t* bx_hdimage_ctl_c::init_image(Bit8u image_mode, Bit64u disk_size,
return hdimage;
}
#ifdef LOWLEVEL_CDROM
LOWLEVEL_CDROM* bx_hdimage_ctl_c::init_cdrom(const char *dev)
{
return new LOWLEVEL_CDROM(dev);
}
#endif
/*** base class device_image_t ***/
device_image_t::device_image_t()

View File

@ -582,6 +582,9 @@ 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);
#ifdef LOWLEVEL_CDROM
virtual LOWLEVEL_CDROM* init_cdrom(const char *dev);
#endif
};

View File

@ -77,6 +77,7 @@ class BOCHSAPI bx_devmodel_c : public logfunctions {
class bx_list_c;
class device_image_t;
class LOWLEVEL_CDROM;
// the best should be deriving of bx_pci_device_stub_c from bx_devmodel_c
// but it make serious problems for cirrus_svga device
@ -370,6 +371,11 @@ public:
virtual device_image_t* init_image(Bit8u image_mode, Bit64u disk_size, const char *journal) {
STUBFUNC(hdimage_ctl, init_image); return NULL;
}
#ifdef LOWLEVEL_CDROM
virtual LOWLEVEL_CDROM* init_cdrom(const char *dev) {
STUBFUNC(hdimage_ctl, init_cdrom); return NULL;
}
#endif
};
#if BX_SUPPORT_SOUNDLOW

View File

@ -228,7 +228,7 @@ 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) {
#ifdef LOWLEVEL_CDROM
s.cdrom = new LOWLEVEL_CDROM(s.fname);
s.cdrom = DEV_hdimage_init_cdrom(s.fname);
if (!s.cdrom->insert_cdrom()) {
BX_ERROR(("could not open cdrom image file '%s'", s.fname));
return 0;

View File

@ -173,6 +173,7 @@ extern "C" {
#define DEV_hd_bmdma_write_sector(a,b) bx_devices.pluginHardDrive->bmdma_write_sector(a,b)
#define DEV_hd_bmdma_complete(a) bx_devices.pluginHardDrive->bmdma_complete(a)
#define DEV_hdimage_init_image(a,b,c) bx_devices.pluginHDImageCtl->init_image(a,b,c)
#define DEV_hdimage_init_cdrom(a) bx_devices.pluginHDImageCtl->init_cdrom(a)
#define DEV_bulk_io_quantum_requested() (bx_devices.bulkIOQuantumsRequested)
#define DEV_bulk_io_quantum_transferred() (bx_devices.bulkIOQuantumsTransferred)