[prev in list] [next in list] [prev in thread] [next in thread]
List: bochs-cvs
Subject: [Bochs-cvs] [12810] trunk/bochs
From: vruppert () users ! sourceforge ! net
Date: 2015-08-23 7:04:57
Message-ID: E1ZTPKu-0001ML-Hv () sfs-ml-4 ! v29 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 12810
Author: vruppert
Date: 2015-08-23 07:04:56 +0000 (Sun, 23 Aug 2015)
Log Message:
-----------
Implemented unregister mechanism for runtime config handlers.
TODO: use it for removable devices with removable media (USB floppy / cdrom).
Modified Paths:
--------------
trunk/bochs/gui/siminterface.cc
trunk/bochs/gui/siminterface.h
trunk/bochs/iodev/floppy.cc
trunk/bochs/iodev/floppy.h
trunk/bochs/iodev/harddrv.cc
trunk/bochs/iodev/harddrv.h
trunk/bochs/iodev/sound/es1370.cc
trunk/bochs/iodev/sound/es1370.h
trunk/bochs/iodev/sound/sb16.cc
trunk/bochs/iodev/sound/sb16.h
trunk/bochs/iodev/usb/usb_ohci.cc
trunk/bochs/iodev/usb/usb_ohci.h
trunk/bochs/iodev/usb/usb_uhci.cc
trunk/bochs/iodev/usb/usb_uhci.h
trunk/bochs/iodev/usb/usb_xhci.cc
trunk/bochs/iodev/usb/usb_xhci.h
Modified: trunk/bochs/gui/siminterface.cc
===================================================================
--- trunk/bochs/gui/siminterface.cc 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/gui/siminterface.cc 2015-08-23 07:04:56 UTC (rev 12810)
@@ -46,7 +46,10 @@
// bx_keyboard.s.internal_buffer[4] (or whatever) directly. -Bryce
//
+static int rt_conf_id = 0;
+
typedef struct _rt_conf_entry_t {
+ int id;
void *device;
rt_conf_handler_t handler;
struct _rt_conf_entry_t *next;
@@ -164,7 +167,8 @@
void *userdata);
virtual int configuration_interface(const char* name, ci_command_t command);
virtual int begin_simulation(int argc, char *argv[]);
- virtual bx_bool register_runtime_config_handler(void *dev, rt_conf_handler_t \
handler); + virtual int register_runtime_config_handler(void *dev, rt_conf_handler_t \
handler); + virtual void unregister_runtime_config_handler(int id);
virtual void update_runtime_options();
virtual void set_sim_thread_func(is_sim_thread_func_t func) {}
virtual bx_bool is_sim_thread();
@@ -875,16 +879,17 @@
return bx_begin_simulation(argc, argv);
}
-bx_bool bx_real_sim_c::register_runtime_config_handler(void *dev, rt_conf_handler_t \
handler) +int bx_real_sim_c::register_runtime_config_handler(void *dev, \
rt_conf_handler_t handler) {
rt_conf_entry_t *rt_conf_entry;
rt_conf_entry = (rt_conf_entry_t *)malloc(sizeof(rt_conf_entry_t));
if (rt_conf_entry == NULL) {
BX_PANIC(("can't allocate rt_conf_entry_t"));
- return 0;
+ return -1;
}
+ rt_conf_entry->id = rt_conf_id;;
rt_conf_entry->device = dev;
rt_conf_entry->handler = handler;
rt_conf_entry->next = NULL;
@@ -899,9 +904,29 @@
}
temp->next = rt_conf_entry;
}
- return 1;
+ return rt_conf_id++;
}
+void bx_real_sim_c::unregister_runtime_config_handler(int id)
+{
+ rt_conf_entry_t *prev = NULL, *next = rt_conf_entries;
+
+ while (next != NULL) {
+ if (next->id == id) {
+ if (prev != NULL) {
+ prev->next = next->next;
+ } else {
+ rt_conf_entries = next->next;
+ }
+ free(next);
+ break;
+ } else {
+ prev = next;
+ next = next->next;
+ }
+ }
+}
+
void bx_real_sim_c::update_runtime_options()
{
rt_conf_entry_t *temp = rt_conf_entries;
Modified: trunk/bochs/gui/siminterface.h
===================================================================
--- trunk/bochs/gui/siminterface.h 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/gui/siminterface.h 2015-08-23 07:04:56 UTC (rev 12810)
@@ -765,7 +765,8 @@
void *userdata) {}
virtual int configuration_interface(const char* name, ci_command_t command) \
{return -1; } virtual int begin_simulation(int argc, char *argv[]) {return -1;}
- virtual bx_bool register_runtime_config_handler(void *dev, rt_conf_handler_t \
handler) {return 0;} + virtual int register_runtime_config_handler(void *dev, \
rt_conf_handler_t handler) {return 0;} + virtual void \
unregister_runtime_config_handler(int id) {} virtual void update_runtime_options() \
{} typedef bx_bool (*is_sim_thread_func_t)();
is_sim_thread_func_t is_sim_thread_func;
Modified: trunk/bochs/iodev/floppy.cc
===================================================================
--- trunk/bochs/iodev/floppy.cc 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/floppy.cc 2015-08-23 07:04:56 UTC (rev 12810)
@@ -126,12 +126,16 @@
put("FLOPPY");
memset(&s, 0, sizeof(s));
s.floppy_timer_index = BX_NULL_TIMER_HANDLE;
+ s.statusbar_id[0] = -1;
+ s.statusbar_id[1] = -1;
+ s.rt_conf_id = -1;
}
bx_floppy_ctrl_c::~bx_floppy_ctrl_c()
{
char pname[10];
+ SIM->unregister_runtime_config_handler(s.rt_conf_id);
for (int i = 0; i < 2; i++) {
close_media(&BX_FD_THIS s.media[i]);
sprintf(pname, "floppy.%d", i);
@@ -302,7 +306,7 @@
SIM->get_param_enum("status", floppy)->set_runtime_param(1);
}
// register handler for correct floppy parameter handling after runtime config
- SIM->register_runtime_config_handler(this, runtime_config_handler);
+ BX_FD_THIS s.rt_conf_id = SIM->register_runtime_config_handler(this, \
runtime_config_handler); #if BX_DEBUGGER
// register device for the 'info device' command (calls debug_dump())
bx_dbg_register_debug_info("floppy", this);
Modified: trunk/bochs/iodev/floppy.h
===================================================================
--- trunk/bochs/iodev/floppy.h 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/floppy.h 2015-08-23 07:04:56 UTC (rev 12810)
@@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2012 The Bochs Project
+// Copyright (C) 2002-2015 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
@@ -127,6 +127,7 @@
Bit8u perp_mode; // perpendicular mode
int statusbar_id[2]; // IDs of the status LEDs
+ int rt_conf_id; // ID of the runtime config handler
} s; // state information
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
Modified: trunk/bochs/iodev/harddrv.cc
===================================================================
--- trunk/bochs/iodev/harddrv.cc 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/harddrv.cc 2015-08-23 07:04:56 UTC (rev 12810)
@@ -132,8 +132,10 @@
channels[channel].drives[device].hdimage = NULL;
channels[channel].drives[device].cdrom.cd = NULL;
channels[channel].drives[device].seek_timer_index = BX_NULL_TIMER_HANDLE;
+ channels[channel].drives[device].statusbar_id = -1;
}
}
+ rt_conf_id = -1;
}
bx_hard_drive_c::~bx_hard_drive_c()
@@ -141,6 +143,7 @@
char ata_name[20];
bx_list_c *base;
+ SIM->unregister_runtime_config_handler(rt_conf_id);
for (Bit8u channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
for (Bit8u device=0; device<2; device ++) {
if (channels[channel].drives[device].hdimage != NULL) {
@@ -271,7 +274,6 @@
// If not present
BX_HD_THIS channels[channel].drives[device].device_type = IDE_NONE;
- BX_HD_THIS channels[channel].drives[device].statusbar_id = -1;
BX_HD_THIS channels[channel].drives[device].identify_set = 0;
if (SIM->get_param_enum("type", base)->get() == BX_ATA_DEVICE_NONE) continue;
@@ -542,7 +544,7 @@
BX_HD_THIS pci_enabled = SIM->get_param_bool(BXPN_PCI_ENABLED)->get();
// register handler for correct cdrom parameter handling after runtime config
- SIM->register_runtime_config_handler(BX_HD_THIS_PTR, runtime_config_handler);
+ BX_HD_THIS rt_conf_id = SIM->register_runtime_config_handler(BX_HD_THIS_PTR, \
runtime_config_handler); }
void bx_hard_drive_c::reset(unsigned type)
Modified: trunk/bochs/iodev/harddrv.h
===================================================================
--- trunk/bochs/iodev/harddrv.h 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/harddrv.h 2015-08-23 07:04:56 UTC (rev 12810)
@@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2014 The Bochs Project
+// Copyright (C) 2001-2015 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
@@ -263,6 +263,7 @@
} channels[BX_MAX_ATA_CHANNEL];
+ int rt_conf_id;
Bit8u cdrom_count;
bx_bool pci_enabled;
};
Modified: trunk/bochs/iodev/sound/es1370.cc
===================================================================
--- trunk/bochs/iodev/sound/es1370.cc 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/sound/es1370.cc 2015-08-23 07:04:56 UTC (rev 12810)
@@ -221,6 +221,7 @@
midiout[1] = NULL;
wavemode = 0;
midimode = 0;
+ s.rt_conf_id = -1;
}
bx_es1370_c::~bx_es1370_c()
@@ -228,6 +229,7 @@
closemidioutput();
closewaveoutput();
+ SIM->unregister_runtime_config_handler(s.rt_conf_id);
SIM->get_bochs_root()->remove("es1370");
bx_list_c *misc_rt = (bx_list_c*)SIM->get_param(BXPN_MENU_RUNTIME_MISC);
misc_rt->remove("es1370");
@@ -326,7 +328,7 @@
SIM->get_param_num("midimode", base)->set_handler(es1370_param_handler);
SIM->get_param_string("midifile", base)->set_handler(es1370_param_string_handler);
// register handler for correct es1370 parameter handling after runtime config
- SIM->register_runtime_config_handler(this, runtime_config_handler);
+ BX_ES1370_THIS s.rt_conf_id = SIM->register_runtime_config_handler(this, \
runtime_config_handler); BX_ES1370_THIS wave_changed = 0;
BX_ES1370_THIS midi_changed = 0;
Modified: trunk/bochs/iodev/sound/es1370.h
===================================================================
--- trunk/bochs/iodev/sound/es1370.h 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/sound/es1370.h 2015-08-23 07:04:56 UTC (rev 12810)
@@ -77,6 +77,7 @@
Bit8u midicmd_index;
Bit8u midi_buffer[256];
+ int rt_conf_id;
Bit8u devfunc;
} bx_es1370_t;
Modified: trunk/bochs/iodev/sound/sb16.cc
===================================================================
--- trunk/bochs/iodev/sound/sb16.cc 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/sound/sb16.cc 2015-08-23 07:04:56 UTC (rev 12810)
@@ -219,10 +219,13 @@
midimode = 0;
loglevel = 0;
logfile = NULL;
+ rt_conf_id = -1;
}
bx_sb16_c::~bx_sb16_c(void)
{
+ SIM->unregister_runtime_config_handler(rt_conf_id);
+
closemidioutput();
if (BX_SB16_WAVEOUT1 != NULL) {
@@ -433,7 +436,7 @@
SIM->get_param_num("loglevel", base)->set_handler(sb16_param_handler);
SIM->get_param_string("log", base)->set_handler(sb16_param_string_handler);
// register handler for correct sb16 parameter handling after runtime config
- SIM->register_runtime_config_handler(this, runtime_config_handler);
+ BX_SB16_THIS rt_conf_id = SIM->register_runtime_config_handler(this, \
runtime_config_handler); BX_SB16_THIS midi_changed = 0;
BX_SB16_THIS wave_changed = 0;
}
Modified: trunk/bochs/iodev/sound/sb16.h
===================================================================
--- trunk/bochs/iodev/sound/sb16.h 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/sound/sb16.h 2015-08-23 07:04:56 UTC (rev 12810)
@@ -159,6 +159,7 @@
int currentdma8;
int currentdma16;
int fmopl_callback_id;
+ int rt_conf_id;
Bit16u fm_volume;
// the MPU 401 relevant variables
Modified: trunk/bochs/iodev/usb/usb_ohci.cc
===================================================================
--- trunk/bochs/iodev/usb/usb_ohci.cc 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/usb/usb_ohci.cc 2015-08-23 07:04:56 UTC (rev 12810)
@@ -134,12 +134,14 @@
memset((void*)&hub, 0, sizeof(bx_usb_ohci_t));
device_buffer = NULL;
hub.frame_timer_index = BX_NULL_TIMER_HANDLE;
+ hub.rt_conf_id = -1;
}
bx_usb_ohci_c::~bx_usb_ohci_c()
{
char pname[16];
+ SIM->unregister_runtime_config_handler(hub.rt_conf_id);
if (BX_OHCI_THIS device_buffer != NULL)
delete [] BX_OHCI_THIS device_buffer;
@@ -207,7 +209,7 @@
}
// register handler for correct device connect handling after runtime config
- SIM->register_runtime_config_handler(BX_OHCI_THIS_PTR, runtime_config_handler);
+ BX_OHCI_THIS hub.rt_conf_id = \
SIM->register_runtime_config_handler(BX_OHCI_THIS_PTR, runtime_config_handler); \
BX_OHCI_THIS hub.device_change = 0;
BX_INFO(("USB OHCI initialized"));
Modified: trunk/bochs/iodev/usb/usb_ohci.h
===================================================================
--- trunk/bochs/iodev/usb/usb_ohci.h 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/usb/usb_ohci.h 2015-08-23 07:04:56 UTC (rev 12810)
@@ -237,6 +237,7 @@
Bit64u sof_time;
Bit8u device_change;
+ int rt_conf_id;
} bx_usb_ohci_t;
Modified: trunk/bochs/iodev/usb/usb_uhci.cc
===================================================================
--- trunk/bochs/iodev/usb/usb_uhci.cc 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/usb/usb_uhci.cc 2015-08-23 07:04:56 UTC (rev 12810)
@@ -121,12 +121,14 @@
memset((void*)&hub, 0, sizeof(bx_usb_uhci_t));
device_buffer = NULL;
hub.timer_index = BX_NULL_TIMER_HANDLE;
+ hub.rt_conf_id = -1;
}
bx_usb_uhci_c::~bx_usb_uhci_c()
{
char pname[16];
+ SIM->unregister_runtime_config_handler(hub.rt_conf_id);
if (BX_UHCI_THIS device_buffer != NULL)
delete [] BX_UHCI_THIS device_buffer;
@@ -193,7 +195,7 @@
}
// register handler for correct device connect handling after runtime config
- SIM->register_runtime_config_handler(BX_UHCI_THIS_PTR, runtime_config_handler);
+ BX_UHCI_THIS hub.rt_conf_id = \
SIM->register_runtime_config_handler(BX_UHCI_THIS_PTR, runtime_config_handler); \
BX_UHCI_THIS hub.device_change = 0;
BX_INFO(("USB UHCI initialized"));
Modified: trunk/bochs/iodev/usb/usb_uhci.h
===================================================================
--- trunk/bochs/iodev/usb/usb_uhci.h 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/usb/usb_uhci.h 2015-08-23 07:04:56 UTC (rev 12810)
@@ -159,6 +159,7 @@
Bit8u devfunc;
Bit8u device_change;
+ int rt_conf_id;
} bx_usb_uhci_t;
#pragma pack (push, 1)
Modified: trunk/bochs/iodev/usb/usb_xhci.cc
===================================================================
--- trunk/bochs/iodev/usb/usb_xhci.cc 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/usb/usb_xhci.cc 2015-08-23 07:04:56 UTC (rev 12810)
@@ -212,6 +212,7 @@
put("usb_xhci", "XHCI");
memset((void*)&hub, 0, sizeof(bx_usb_xhci_t));
device_buffer = NULL;
+ hub.rt_conf_id = -1;
//hub.frame_timer_index = BX_NULL_TIMER_HANDLE;
}
@@ -219,6 +220,7 @@
{
char pname[16];
+ SIM->unregister_runtime_config_handler(hub.rt_conf_id);
if (BX_XHCI_THIS device_buffer != NULL)
delete [] BX_XHCI_THIS device_buffer;
@@ -293,7 +295,7 @@
}
// register handler for correct device connect handling after runtime config
- SIM->register_runtime_config_handler(BX_XHCI_THIS_PTR, runtime_config_handler);
+ BX_XHCI_THIS hub.rt_conf_id = \
SIM->register_runtime_config_handler(BX_XHCI_THIS_PTR, runtime_config_handler); \
BX_XHCI_THIS hub.device_change = 0;
for (i=0; i<USB_XHCI_PORTS; i++)
Modified: trunk/bochs/iodev/usb/usb_xhci.h
===================================================================
--- trunk/bochs/iodev/usb/usb_xhci.h 2015-08-22 06:19:13 UTC (rev 12809)
+++ trunk/bochs/iodev/usb/usb_xhci.h 2015-08-23 07:04:56 UTC (rev 12810)
@@ -526,6 +526,7 @@
Bit8u devfunc;
Bit8u device_change;
+ int rt_conf_id;
} bx_usb_xhci_t;
// Version 3.0.23.0 of the Renesas uPD720202 driver, even though the card is
------------------------------------------------------------------------------
_______________________________________________
Bochs-cvs mailing list
Bochs-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bochs-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic