- new cdrom button in the headerbar

- changing cdrom media in a Bochs session now possible
- don't eject cdrom when the guest OS has locked the drive
This commit is contained in:
Volker Ruppert 2002-02-01 16:46:27 +00:00
parent 8a07e04cc2
commit 84b649831e
6 changed files with 102 additions and 17 deletions

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.24 2001-11-09 22:17:33 bdenney Exp $
// $Id: gui.cc,v 1.25 2002-02-01 16:46:27 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
// Copyright (C) 2002 MandrakeSoft S.A.
//
// MandrakeSoft S.A.
// 43, rue d'Aboukir
@ -34,6 +34,7 @@
#include "gui/bitmaps/power.h"
#include "gui/bitmaps/snapshot.h"
#include "gui/bitmaps/configbutton.h"
#include "gui/bitmaps/cdromd.h"
#if BX_WITH_MACOS
# include <Disks.h>
#endif
@ -66,6 +67,10 @@ bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
BX_FLOPPYB_BMAP_X, BX_FLOPPYB_BMAP_Y);
BX_GUI_THIS floppyB_eject_bmap_id = create_bitmap(bx_floppyb_eject_bmap,
BX_FLOPPYB_BMAP_X, BX_FLOPPYB_BMAP_Y);
BX_GUI_THIS cdromD_bmap_id = create_bitmap(bx_cdromd_bmap,
BX_CDROMD_BMAP_X, BX_CDROMD_BMAP_Y);
BX_GUI_THIS cdromD_eject_bmap_id = create_bitmap(bx_cdromd_eject_bmap,
BX_CDROMD_BMAP_X, BX_CDROMD_BMAP_Y);
BX_GUI_THIS mouse_bmap_id = create_bitmap(bx_mouse_bmap,
BX_MOUSE_BMAP_X, BX_MOUSE_BMAP_Y);
BX_GUI_THIS nomouse_bmap_id = create_bitmap(bx_nomouse_bmap,
@ -99,6 +104,17 @@ bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
BX_GUI_THIS floppyB_hbar_id = headerbar_bitmap(BX_GUI_THIS floppyB_eject_bmap_id,
BX_GRAVITY_LEFT, floppyB_handler);
// CDROM
BX_GUI_THIS cdromD_status =
bx_devices.hard_drive->get_cd_media_status()
&& bx_options.cdromd.Opresent->get ();
if (BX_GUI_THIS cdromD_status)
BX_GUI_THIS cdromD_hbar_id = headerbar_bitmap(BX_GUI_THIS cdromD_bmap_id,
BX_GRAVITY_LEFT, cdromD_handler);
else
BX_GUI_THIS cdromD_hbar_id = headerbar_bitmap(BX_GUI_THIS cdromD_eject_bmap_id,
BX_GRAVITY_LEFT, cdromD_handler);
// Mouse button
if (bx_options.Omouse_enabled->get ())
BX_GUI_THIS mouse_hbar_id = headerbar_bitmap(BX_GUI_THIS mouse_bmap_id,
@ -131,6 +147,9 @@ bx_gui_c::update_floppy_status_buttons (void) {
BX_GUI_THIS floppyB_status =
bx_devices.floppy->get_media_status (1)
&& bx_options.floppyb.Oinitial_status->get ();
BX_GUI_THIS cdromD_status =
bx_devices.hard_drive->get_cd_media_status()
&& bx_options.cdromd.Opresent->get ();
if (BX_GUI_THIS floppyA_status)
replace_bitmap(BX_GUI_THIS floppyA_hbar_id, BX_GUI_THIS floppyA_bmap_id);
else {
@ -153,6 +172,11 @@ bx_gui_c::update_floppy_status_buttons (void) {
#endif
replace_bitmap(BX_GUI_THIS floppyB_hbar_id, BX_GUI_THIS floppyB_eject_bmap_id);
}
if (BX_GUI_THIS cdromD_status)
replace_bitmap(BX_GUI_THIS cdromD_hbar_id, BX_GUI_THIS cdromD_bmap_id);
else {
replace_bitmap(BX_GUI_THIS cdromD_hbar_id, BX_GUI_THIS cdromD_eject_bmap_id);
}
}
void
@ -171,6 +195,14 @@ bx_gui_c::floppyB_handler(void)
BX_GUI_THIS update_floppy_status_buttons ();
}
void
bx_gui_c::cdromD_handler(void)
{
BX_GUI_THIS cdromD_status =
bx_devices.hard_drive->set_cd_media_status(!BX_GUI_THIS cdromD_status);
BX_GUI_THIS update_floppy_status_buttons ();
}
void
bx_gui_c::reset_handler(void)
{

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.h,v 1.19 2001-12-22 00:00:33 cbothamy Exp $
// $Id: gui.h,v 1.20 2002-02-01 16:46:27 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
// Copyright (C) 2002 MandrakeSoft S.A.
//
// MandrakeSoft S.A.
// 43, rue d'Aboukir
@ -73,6 +73,7 @@ private:
// And these are defined and used privately in gui.cc
static void floppyA_handler(void);
static void floppyB_handler(void);
static void cdromD_handler(void);
static void reset_handler(void);
static void power_handler(void);
static void snapshot_handler(void);
@ -81,8 +82,10 @@ private:
Boolean floppyA_status;
Boolean floppyB_status;
Boolean cdromD_status;
unsigned floppyA_bmap_id, floppyA_eject_bmap_id, floppyA_hbar_id;
unsigned floppyB_bmap_id, floppyB_eject_bmap_id, floppyB_hbar_id;
unsigned cdromD_bmap_id, cdromD_eject_bmap_id, cdromD_hbar_id;
unsigned power_bmap_id, power_hbar_id;
unsigned reset_bmap_id, reset_hbar_id;
unsigned snapshot_bmap_id, snapshot_hbar_id;
@ -91,8 +94,8 @@ private:
};
#define BX_MAX_PIXMAPS 10
#define BX_MAX_HEADERBAR_ENTRIES 7
#define BX_MAX_PIXMAPS 12
#define BX_MAX_HEADERBAR_ENTRIES 8
#define BX_HEADER_BAR_Y 32
// align pixmaps towards left or right side of header bar

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cdrom.cc,v 1.26 2001-12-10 18:37:39 bdenney Exp $
// $Id: cdrom.cc,v 1.27 2002-02-01 16:46:27 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
// Copyright (C) 2002 MandrakeSoft S.A.
//
// MandrakeSoft S.A.
// 43, rue d'Aboukir
@ -199,9 +199,10 @@ cdrom_interface::cdrom_interface(char *dev)
}
using_file=0;
}
void
cdrom_interface::init(void) {
BX_DEBUG(("Init $Id: cdrom.cc,v 1.26 2001-12-10 18:37:39 bdenney Exp $"));
BX_DEBUG(("Init $Id: cdrom.cc,v 1.27 2002-02-01 16:46:27 vruppert Exp $"));
BX_INFO(("file = '%s'",path));
}
@ -215,13 +216,14 @@ cdrom_interface::~cdrom_interface(void)
}
bool
cdrom_interface::insert_cdrom()
cdrom_interface::insert_cdrom(char *dev)
{
unsigned char buffer[BX_CD_FRAMESIZE];
ssize_t ret;
struct stat stat_buf;
// Load CD-ROM. Returns false if CD is not ready.
if (dev != NULL) path = strdup(dev);
BX_INFO (("load cdrom with path=%s", path));
#ifdef WIN32
char drive[256];

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cdrom.h,v 1.6 2001-10-03 13:10:38 bdenney Exp $
// $Id: cdrom.h,v 1.7 2002-02-01 16:46:27 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
// Copyright (C) 2002 MandrakeSoft S.A.
//
// MandrakeSoft S.A.
// 43, rue d'Aboukir
@ -35,7 +35,7 @@ public:
void init(void);
// Load CD-ROM. Returns false if CD is not ready.
bool insert_cdrom();
bool insert_cdrom(char *dev = NULL);
// Logically eject the CD.
void eject_cdrom();

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: harddrv.cc,v 1.46 2002-01-30 10:30:52 cbothamy Exp $
// $Id: harddrv.cc,v 1.47 2002-02-01 16:46:27 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -128,7 +128,7 @@ bx_hard_drive_c::~bx_hard_drive_c(void)
bx_hard_drive_c::init(bx_devices_c *d, bx_cmos_c *cmos)
{
BX_HD_THIS devices = d;
BX_DEBUG(("Init $Id: harddrv.cc,v 1.46 2002-01-30 10:30:52 cbothamy Exp $"));
BX_DEBUG(("Init $Id: harddrv.cc,v 1.47 2002-02-01 16:46:27 vruppert Exp $"));
/* HARD DRIVE 0 */
@ -2617,6 +2617,52 @@ bx_hard_drive_c::command_aborted(unsigned value)
raise_interrupt();
}
unsigned
bx_hard_drive_c::get_cd_media_status(void)
{
return( BX_HD_THIS s[1].cdrom.ready );
}
unsigned
bx_hard_drive_c::set_cd_media_status(unsigned status)
{
// if setting to the current value, nothing to do
if (status == BX_HD_THIS s[1].cdrom.ready)
return(status);
// return 0 if no cdromd is present
if (!bx_options.cdromd.Opresent->get())
return(0);
if (status == 0) {
// eject cdrom if not locked by guest OS
if (BX_HD_THIS s[1].cdrom.locked) return(1);
else {
#ifdef LOWLEVEL_CDROM
BX_HD_THIS s[1].cdrom.cd->eject_cdrom();
#endif
BX_HD_THIS s[1].cdrom.ready = 0;
bx_options.cdromd.Oinserted->set(BX_EJECTED);
}
}
else {
// insert cdrom
#ifdef LOWLEVEL_CDROM
if (BX_HD_THIS s[1].cdrom.cd->insert_cdrom(bx_options.cdromd.Opath->getptr())) {
BX_INFO(( "Media present in CD-ROM drive"));
BX_HD_THIS s[1].cdrom.ready = 1;
BX_HD_THIS s[1].cdrom.capacity = BX_HD_THIS s[1].cdrom.cd->capacity();
bx_options.cdromd.Oinserted->set(BX_INSERTED);
}
else {
BX_INFO(( "Could not locate CD-ROM, continuing with media not present"));
BX_HD_THIS s[1].cdrom.ready = 0;
bx_options.cdromd.Oinserted->set(BX_EJECTED);
}
#endif
}
return( BX_HD_THIS s[1].cdrom.ready );
}
/*** default_image_t function definitions ***/

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////
// $Id: harddrv.h,v 1.7 2001-10-06 09:04:39 bdenney Exp $
// $Id: harddrv.h,v 1.8 2002-02-01 16:46:27 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
// Copyright (C) 2002 MandrakeSoft S.A.
//
// MandrakeSoft S.A.
// 43, rue d'Aboukir
@ -263,6 +263,8 @@ public:
~bx_hard_drive_c(void);
BX_HD_SMF void close_harddrive(void);
BX_HD_SMF void init(bx_devices_c *d, bx_cmos_c *cmos);
BX_HD_SMF unsigned get_cd_media_status(void);
BX_HD_SMF unsigned set_cd_media_status(unsigned status);
#if !BX_USE_HD_SMF
Bit32u read(Bit32u address, unsigned io_len);