- added runtime config handler for the ATAPI cdrom code. Now the media change is handled after both
parameters (path + status) have been set. TODO: implement this feature for the floppy, too. - call update_drive_status_buttons() from update_runtime_options() to reduce the number of calls. Now call update_runtime_options() from the gui floppy / cdrom handlers after closing dialog.
This commit is contained in:
parent
c1b278f36e
commit
c8d2f60225
@ -299,7 +299,7 @@ void bx_gui_c::floppyA_handler(void)
|
||||
// image you want to switch to.
|
||||
int ret = SIM->ask_param(BXPN_FLOPPYA_PATH);
|
||||
if (ret > 0) {
|
||||
BX_GUI_THIS update_drive_status_buttons();
|
||||
SIM->update_runtime_options();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -317,7 +317,7 @@ void bx_gui_c::floppyB_handler(void)
|
||||
// image you want to switch to.
|
||||
int ret = SIM->ask_param(BXPN_FLOPPYB_PATH);
|
||||
if (ret > 0) {
|
||||
BX_GUI_THIS update_drive_status_buttons();
|
||||
SIM->update_runtime_options();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -339,7 +339,7 @@ void bx_gui_c::cdrom1_handler(void)
|
||||
return; // no cdrom found
|
||||
int ret = SIM->ask_param(cdrom);
|
||||
if (ret > 0) {
|
||||
BX_GUI_THIS update_drive_status_buttons();
|
||||
SIM->update_runtime_options();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2009 The Bochs Project
|
||||
// Copyright (C) 2002-2011 The Bochs Project
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -835,6 +835,7 @@ void bx_real_sim_c::update_runtime_options()
|
||||
temp->handler(temp->device);
|
||||
temp = temp->next;
|
||||
}
|
||||
bx_gui->update_drive_status_buttons();
|
||||
}
|
||||
|
||||
bx_bool bx_real_sim_c::is_sim_thread()
|
||||
|
@ -1931,10 +1931,8 @@ Bit64s bx_floppy_ctrl_c::floppy_param_handler(bx_param_c *param, int set, Bit64s
|
||||
param->get_param_path(pname, BX_PATHNAME_LEN);
|
||||
if (!strcmp(pname, BXPN_FLOPPYA_STATUS)) {
|
||||
BX_FD_THIS set_media_status(0, (bx_bool)val);
|
||||
bx_gui->update_drive_status_buttons();
|
||||
} else if (!strcmp(pname, BXPN_FLOPPYB_STATUS)) {
|
||||
BX_FD_THIS set_media_status(1, (bx_bool)val);
|
||||
bx_gui->update_drive_status_buttons();
|
||||
} else if (!strcmp(pname, BXPN_FLOPPYA_READONLY)) {
|
||||
BX_FD_THIS s.media[0].write_protected = (bx_bool)val;
|
||||
} else if (!strcmp(pname, BXPN_FLOPPYB_READONLY)) {
|
||||
@ -1963,7 +1961,6 @@ const char* bx_floppy_ctrl_c::floppy_param_string_handler(bx_param_string_c *par
|
||||
device = atoi(base->get_name());
|
||||
if (empty) {
|
||||
BX_FD_THIS set_media_status(device, 0);
|
||||
bx_gui->update_drive_status_buttons();
|
||||
} else {
|
||||
if (SIM->get_param_enum("devtype", base)->get() == BX_FDD_NONE) {
|
||||
BX_ERROR(("Cannot add a floppy drive at runtime"));
|
||||
|
@ -564,6 +564,9 @@ void bx_hard_drive_c::init(void)
|
||||
BX_HD_THIS iolight_timer_index =
|
||||
DEV_register_timer(this, iolight_timer_handler, 100000, 0,0, "HD/CD i/o light");
|
||||
}
|
||||
|
||||
// register handler for correct cdrom parameter handling after runtime config
|
||||
SIM->register_runtime_config_handler(BX_HD_THIS_PTR, runtime_config_handler);
|
||||
}
|
||||
|
||||
void bx_hard_drive_c::reset(unsigned type)
|
||||
@ -650,6 +653,35 @@ void bx_hard_drive_c::iolight_timer()
|
||||
}
|
||||
}
|
||||
|
||||
void bx_hard_drive_c::runtime_config_handler(void *this_ptr)
|
||||
{
|
||||
bx_hard_drive_c *class_ptr = (bx_hard_drive_c *) this_ptr;
|
||||
class_ptr->runtime_config();
|
||||
}
|
||||
|
||||
void bx_hard_drive_c::runtime_config(void)
|
||||
{
|
||||
char pname[16];
|
||||
int handle;
|
||||
bx_bool status;
|
||||
|
||||
for (Bit8u channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
|
||||
for (Bit8u device=0; device<2; device++) {
|
||||
if (BX_HD_THIS channels[channel].drives[device].status_changed) {
|
||||
handle = (channel << 1) | device;
|
||||
sprintf(pname, "ata.%d.%s", channel, device ? "slave":"master");
|
||||
bx_list_c *base = (bx_list_c*) SIM->get_param(pname);
|
||||
status = SIM->get_param_bool("status", base)->get();
|
||||
BX_HD_THIS set_cd_media_status(handle, 0);
|
||||
if (status == 1) {
|
||||
BX_HD_THIS set_cd_media_status(handle, status);
|
||||
}
|
||||
BX_HD_THIS channels[channel].drives[device].status_changed = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define GOTO_RETURN_VALUE if(io_len==4) { \
|
||||
goto return_value32; \
|
||||
} \
|
||||
@ -3127,7 +3159,7 @@ bx_bool bx_hard_drive_c::set_cd_media_status(Bit32u handle, bx_bool status)
|
||||
{
|
||||
char ata_name[20];
|
||||
|
||||
BX_DEBUG (("set_cd_media_status handle=%d status=%d", handle, status));
|
||||
BX_DEBUG(("set_cd_media_status handle=%d status=%d", handle, status));
|
||||
if (handle >= BX_MAX_ATA_CHANNEL*2) return 0;
|
||||
|
||||
Bit8u channel = handle / 2;
|
||||
@ -3138,7 +3170,7 @@ bx_bool bx_hard_drive_c::set_cd_media_status(Bit32u handle, bx_bool status)
|
||||
// if setting to the current value, nothing to do
|
||||
if (status == BX_HD_THIS channels[channel].drives[device].cdrom.ready)
|
||||
return(status);
|
||||
// return 0 if no cdromd is present
|
||||
// return 0 if selected drive is not a cdrom
|
||||
if (!BX_DRIVE_IS_CD(channel,device))
|
||||
return(0);
|
||||
|
||||
@ -3429,8 +3461,7 @@ Bit64s bx_hard_drive_c::cdrom_status_handler(bx_param_c *param, int set, Bit64s
|
||||
handle = get_device_handle_from_param(param);
|
||||
if (handle >= 0) {
|
||||
if (!strcmp(param->get_name(), "status")) {
|
||||
DEV_hd_set_cd_media_status((Bit32u)handle, (bx_bool)val);
|
||||
bx_gui->update_drive_status_buttons();
|
||||
BX_HD_THIS channels[handle/2].drives[handle%2].status_changed = 1;
|
||||
}
|
||||
} else {
|
||||
BX_PANIC(("cdrom_status_handler called with unexpected parameter '%s'", param->get_name()));
|
||||
@ -3445,25 +3476,13 @@ const char *bx_hard_drive_c::cdrom_path_handler(bx_param_string_c *param, int se
|
||||
int handle;
|
||||
|
||||
if (set) {
|
||||
int empty = 0;
|
||||
if ((strlen(val) < 1) || !strcmp ("none", val)) {
|
||||
empty = 1;
|
||||
if (strlen(val) < 1) {
|
||||
val = "none";
|
||||
}
|
||||
handle = get_device_handle_from_param(param);
|
||||
if (handle >= 0) {
|
||||
if (!strcmp(param->get_name(), "path")) {
|
||||
if (empty) {
|
||||
DEV_hd_set_cd_media_status((Bit32u)handle, 0);
|
||||
bx_gui->update_drive_status_buttons();
|
||||
} else {
|
||||
bx_list_c *base = (bx_list_c*) param->get_parent();
|
||||
if (SIM->get_param_num("status", base)->get() == 1) {
|
||||
// tell the device model that we removed, then inserted the cd
|
||||
DEV_hd_set_cd_media_status((Bit32u)handle, 0);
|
||||
DEV_hd_set_cd_media_status((Bit32u)handle, 1);
|
||||
}
|
||||
}
|
||||
BX_HD_THIS channels[handle/2].drives[handle%2].status_changed = 1;
|
||||
}
|
||||
} else {
|
||||
BX_PANIC(("cdrom_path_handler called with unexpected parameter '%s'", param->get_name()));
|
||||
|
@ -153,9 +153,11 @@ struct atapi_t
|
||||
#if BX_USE_HD_SMF
|
||||
# define BX_HD_SMF static
|
||||
# define BX_HD_THIS theHardDrive->
|
||||
# define BX_HD_THIS_PTR theHardDrive
|
||||
#else
|
||||
# define BX_HD_SMF
|
||||
# define BX_HD_THIS this->
|
||||
# define BX_HD_THIS_PTR this
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
@ -198,6 +200,9 @@ public:
|
||||
static void iolight_timer_handler(void *);
|
||||
BX_HD_SMF void iolight_timer(void);
|
||||
|
||||
static void runtime_config_handler(void *);
|
||||
void runtime_config(void);
|
||||
|
||||
private:
|
||||
|
||||
BX_HD_SMF bx_bool calculate_logical_address(Bit8u channel, Bit64s *sector) BX_CPP_AttrRegparmN(2);
|
||||
@ -245,6 +250,7 @@ private:
|
||||
int statusbar_id;
|
||||
int iolight_counter;
|
||||
Bit8u device_num; // for ATAPI identify & inquiry
|
||||
bx_bool status_changed;
|
||||
} drives[2];
|
||||
unsigned drive_select;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user