From 95e3a7141d53b1f3e121eab858638e7cd1885e91 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Sun, 19 Aug 2012 11:45:50 +0000 Subject: [PATCH] - reset config options support for the optional plugin control. Unload all the plugins from the list and load the default set. - initialize save/restore support earlier to avoid segfault when unloading plugin --- bochs/config.cc | 46 ++++++++++++++++++++++++++++++++-------------- bochs/main.cc | 2 +- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/bochs/config.cc b/bochs/config.cc index 2915733f8..78e904547 100644 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -242,6 +242,33 @@ void bx_init_usb_options(const char *usb_name, const char *pname, int maxports) enabled->set_dependent_list(deplist); } +void bx_plugin_ctrl_reset(bx_bool init_done) +{ + bx_list_c *base = (bx_list_c*) SIM->get_param(BXPN_PLUGIN_CTRL); + if (init_done) { + for (int i = 0; i < base->get_size(); i++) { + ((bx_param_bool_c*)base->get(i))->set(0); + } + SIM->opt_plugin_ctrl("*", 0); + } + // add the default set of plugins to the list + new bx_param_bool_c(base, "unmapped", "", "", 1); + new bx_param_bool_c(base, "biosdev", "", "", 1); + new bx_param_bool_c(base, "speaker", "", "", 1); + new bx_param_bool_c(base, "extfpuirq", "", "", 1); + new bx_param_bool_c(base, "parallel", "", "", 1); + new bx_param_bool_c(base, "serial", "", "", 1); +#if BX_SUPPORT_GAMEPORT + new bx_param_bool_c(base, "gameport", "", "", 1); +#endif +#if BX_SUPPORT_IODEBUG && BX_DEBUGGER + new bx_param_bool_c(base, "iodebug", "", "", 1); +#endif + if (init_done) { + SIM->opt_plugin_ctrl("*", 1); + } +} + void bx_init_options() { int i; @@ -317,20 +344,8 @@ void bx_init_options() new bx_list_c(logfn, "panic", ""); // optional plugin control - menu = new bx_list_c(menu, "plugin_ctrl", "Optional Plugin Control"); - // add the default set of plugins to the list - new bx_param_bool_c(menu, "unmapped", "", "", 1); - new bx_param_bool_c(menu, "biosdev", "", "", 1); - new bx_param_bool_c(menu, "speaker", "", "", 1); - new bx_param_bool_c(menu, "extfpuirq", "", "", 1); - new bx_param_bool_c(menu, "parallel", "", "", 1); - new bx_param_bool_c(menu, "serial", "", "", 1); -#if BX_SUPPORT_GAMEPORT - new bx_param_bool_c(menu, "gameport", "", "", 1); -#endif -#if BX_SUPPORT_IODEBUG && BX_DEBUGGER - new bx_param_bool_c(menu, "iodebug", "", "", 1); -#endif + new bx_list_c(menu, "plugin_ctrl", "Optional Plugin Control"); + bx_plugin_ctrl_reset(0); // subtree for special menus bx_list_c *special_menus = new bx_list_c(root_param, "menu", ""); @@ -1555,6 +1570,9 @@ void bx_init_options() void bx_reset_options() { + // optional plugin control + bx_plugin_ctrl_reset(1); + // cpu SIM->get_param("cpu")->reset(); diff --git a/bochs/main.cc b/bochs/main.cc index fa4ce4d87..fd82425be 100644 --- a/bochs/main.cc +++ b/bochs/main.cc @@ -808,6 +808,7 @@ int bx_init_main(int argc, char *argv[]) } // load pre-defined optional plugins before parsing configuration SIM->opt_plugin_ctrl("*", 1); + SIM->init_save_restore(); if (load_rcfile) { // parse configuration file and command line arguments #ifdef WIN32 @@ -942,7 +943,6 @@ bx_bool load_and_init_display_lib(void) int bx_begin_simulation (int argc, char *argv[]) { - SIM->init_save_restore(); if (SIM->get_param_bool(BXPN_RESTORE_FLAG)->get()) { if (!SIM->restore_config()) { BX_PANIC(("cannot restore configuration"));