- unlimited number of user options after rewrite (now using a chain similar to
the plugin device code) - minor updates
This commit is contained in:
parent
ee1e10ab73
commit
65eacd8063
@ -1,4 +1,4 @@
|
|||||||
$Id: PARAM_TREE.txt,v 1.18 2009-01-04 21:46:20 vruppert Exp $
|
$Id: PARAM_TREE.txt,v 1.19 2009-01-06 20:35:38 vruppert Exp $
|
||||||
|
|
||||||
Starting from Bochs 2.3 the parameters are organized in a tree structure
|
Starting from Bochs 2.3 the parameters are organized in a tree structure
|
||||||
instead of a huge flat list. The parameter tree was required for implementing
|
instead of a huge flat list. The parameter tree was required for implementing
|
||||||
@ -239,4 +239,4 @@ wxdebug
|
|||||||
user
|
user
|
||||||
(subtree for user-defined options)
|
(subtree for user-defined options)
|
||||||
|
|
||||||
(updated Oct 8, 2006 by vruppert)
|
(updated Jan 6, 2008 by vruppert)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// $Id: config.cc,v 1.147 2009-01-04 21:46:20 vruppert Exp $
|
// $Id: config.cc,v 1.148 2009-01-06 20:35:38 vruppert Exp $
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||||
@ -22,7 +22,7 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "bochs.h"
|
#include "bochs.h"
|
||||||
#include "iodev/iodev.h"
|
#include "iodev/iodev.h"
|
||||||
@ -3212,9 +3212,9 @@ static int parse_line_formatted(const char *context, int num_params, char *param
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// user-defined options handled by registered functions
|
// user-defined options handled by registered functions
|
||||||
else if ((i = SIM->find_user_option(params[0])) >= 0)
|
else if (SIM->is_user_option(params[0]))
|
||||||
{
|
{
|
||||||
return SIM->parse_user_option(i, context, num_params, ¶ms[0]);
|
return SIM->parse_user_option(context, num_params, ¶ms[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// $Id: siminterface.cc,v 1.186 2009-01-05 21:15:17 vruppert Exp $
|
// $Id: siminterface.cc,v 1.187 2009-01-06 20:35:39 vruppert Exp $
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// See siminterface.h for description of the siminterface concept.
|
// See siminterface.h for description of the siminterface concept.
|
||||||
@ -14,8 +14,6 @@ logfunctions *siminterface_log = NULL;
|
|||||||
bx_list_c *root_param = NULL;
|
bx_list_c *root_param = NULL;
|
||||||
#define LOG_THIS siminterface_log->
|
#define LOG_THIS siminterface_log->
|
||||||
|
|
||||||
#define BX_MAX_USER_OPTIONS 16
|
|
||||||
|
|
||||||
// bx_simulator_interface just defines the interface that the Bochs simulator
|
// bx_simulator_interface just defines the interface that the Bochs simulator
|
||||||
// and the gui will use to talk to each other. None of the methods of
|
// and the gui will use to talk to each other. None of the methods of
|
||||||
// bx_simulator_interface are implemented; they are all virtual. The
|
// bx_simulator_interface are implemented; they are all virtual. The
|
||||||
@ -29,10 +27,11 @@ bx_list_c *root_param = NULL;
|
|||||||
// bx_keyboard.s.internal_buffer[4] (or whatever) directly. -Bryce
|
// bx_keyboard.s.internal_buffer[4] (or whatever) directly. -Bryce
|
||||||
//
|
//
|
||||||
|
|
||||||
typedef struct {
|
typedef struct _user_option_t {
|
||||||
const char *name;
|
const char *name;
|
||||||
user_option_parser_t parser;
|
user_option_parser_t parser;
|
||||||
user_option_save_t savefn;
|
user_option_save_t savefn;
|
||||||
|
struct _user_option_t *next;
|
||||||
} user_option_t;
|
} user_option_t;
|
||||||
|
|
||||||
class bx_real_sim_c : public bx_simulator_interface_c {
|
class bx_real_sim_c : public bx_simulator_interface_c {
|
||||||
@ -41,8 +40,7 @@ class bx_real_sim_c : public bx_simulator_interface_c {
|
|||||||
const char *registered_ci_name;
|
const char *registered_ci_name;
|
||||||
config_interface_callback_t ci_callback;
|
config_interface_callback_t ci_callback;
|
||||||
void *ci_callback_data;
|
void *ci_callback_data;
|
||||||
int n_user_options;
|
user_option_t *user_options;
|
||||||
user_option_t user_option[BX_MAX_USER_OPTIONS];
|
|
||||||
int init_done;
|
int init_done;
|
||||||
int enabled;
|
int enabled;
|
||||||
// save context to jump to if we must quit unexpectedly
|
// save context to jump to if we must quit unexpectedly
|
||||||
@ -143,10 +141,10 @@ public:
|
|||||||
}
|
}
|
||||||
virtual bx_bool test_for_text_console();
|
virtual bx_bool test_for_text_console();
|
||||||
// user-defined option support
|
// user-defined option support
|
||||||
virtual int find_user_option(const char *keyword);
|
|
||||||
virtual bx_bool register_user_option(const char *keyword, user_option_parser_t parser, user_option_save_t save_func);
|
virtual bx_bool register_user_option(const char *keyword, user_option_parser_t parser, user_option_save_t save_func);
|
||||||
virtual bx_bool unregister_user_option(const char *keyword);
|
virtual bx_bool unregister_user_option(const char *keyword);
|
||||||
virtual Bit32s parse_user_option(int idx, const char *context, int num_params, char *params []);
|
virtual bx_bool is_user_option(const char *keyword);
|
||||||
|
virtual Bit32s parse_user_option(const char *context, int num_params, char *params []);
|
||||||
virtual Bit32s save_user_options(FILE *fp);
|
virtual Bit32s save_user_options(FILE *fp);
|
||||||
|
|
||||||
// save/restore support
|
// save/restore support
|
||||||
@ -294,7 +292,7 @@ bx_real_sim_c::bx_real_sim_c()
|
|||||||
quit_context = NULL;
|
quit_context = NULL;
|
||||||
exit_code = 0;
|
exit_code = 0;
|
||||||
param_id = BXP_NEW_PARAM_ID;
|
param_id = BXP_NEW_PARAM_ID;
|
||||||
n_user_options = 0;
|
user_options = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bx_real_sim_c::reset_all_param()
|
void bx_real_sim_c::reset_all_param()
|
||||||
@ -777,69 +775,90 @@ bx_bool bx_real_sim_c::test_for_text_console()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bx_real_sim_c::find_user_option(const char *keyword)
|
bx_bool bx_real_sim_c::is_user_option(const char *keyword)
|
||||||
{
|
{
|
||||||
int i = 0;
|
user_option_t *user_option;
|
||||||
while (i < n_user_options) {
|
|
||||||
if (!strcmp(keyword, user_option[i].name)) {
|
for (user_option = user_options; user_option; user_option = user_option->next) {
|
||||||
return i;
|
if (!strcmp(user_option->name, keyword)) return 1;
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bx_bool bx_real_sim_c::register_user_option(const char *keyword, user_option_parser_t parser,
|
bx_bool bx_real_sim_c::register_user_option(const char *keyword, user_option_parser_t parser,
|
||||||
user_option_save_t save_func)
|
user_option_save_t save_func)
|
||||||
{
|
{
|
||||||
if (n_user_options >= BX_MAX_USER_OPTIONS) {
|
user_option_t *user_option;
|
||||||
|
|
||||||
|
user_option = (user_option_t *)malloc(sizeof(user_option_t));
|
||||||
|
if (user_option == NULL) {
|
||||||
|
BX_PANIC(("can't allocate user_option_t"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int idx = find_user_option(keyword);
|
|
||||||
if (idx >= 0) {
|
user_option->name = keyword;
|
||||||
if (parser == user_option[idx].parser) {
|
user_option->parser = parser;
|
||||||
// parse handler already registered
|
user_option->savefn = save_func;
|
||||||
return 1;
|
user_option->next = NULL;
|
||||||
} else {
|
|
||||||
// keyword already exists
|
if (user_options == NULL) {
|
||||||
return 0;
|
user_options = user_option;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
idx = n_user_options++;
|
user_option_t *temp = user_options;
|
||||||
user_option[idx].name = keyword;
|
|
||||||
user_option[idx].parser = parser;
|
while (temp->next) {
|
||||||
user_option[idx].savefn = save_func;
|
if (!strcmp(temp->name, keyword)) {
|
||||||
return 1;
|
free(user_option);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
temp->next = user_option;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bx_bool bx_real_sim_c::unregister_user_option(const char *keyword)
|
bx_bool bx_real_sim_c::unregister_user_option(const char *keyword)
|
||||||
{
|
{
|
||||||
int idx = find_user_option(keyword);
|
user_option_t *user_option, *prev = NULL;
|
||||||
if (idx >= 0) {
|
|
||||||
for (int i = idx; i < n_user_options; i++) {
|
for (user_option = user_options; user_option; user_option = user_option->next) {
|
||||||
user_option[i] = user_option[i+1];
|
if (!strcmp(user_option->name, keyword)) {
|
||||||
|
if (prev == NULL) {
|
||||||
|
user_options = user_option->next;
|
||||||
|
} else {
|
||||||
|
prev->next = user_option->next;
|
||||||
|
}
|
||||||
|
free(user_option);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
prev = user_option;
|
||||||
}
|
}
|
||||||
n_user_options--;
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bit32s bx_real_sim_c::parse_user_option(int idx, const char *context, int num_params, char *params [])
|
Bit32s bx_real_sim_c::parse_user_option(const char *context, int num_params, char *params [])
|
||||||
{
|
{
|
||||||
if (idx < 0 || idx >= n_user_options) {
|
user_option_t *user_option;
|
||||||
return -1;
|
|
||||||
|
for (user_option = user_options; user_option; user_option = user_option->next) {
|
||||||
|
if ((!strcmp(user_option->name, params[0])) &&
|
||||||
|
(user_option->parser != NULL)) {
|
||||||
|
return (*user_option->parser)(context, num_params, params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (*user_option[idx].parser)(context, num_params, params);
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bit32s bx_real_sim_c::save_user_options(FILE *fp)
|
Bit32s bx_real_sim_c::save_user_options(FILE *fp)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < n_user_options; i++) {
|
user_option_t *user_option;
|
||||||
if (user_option[i].savefn != NULL) {
|
|
||||||
(*user_option[i].savefn)(fp);
|
for (user_option = user_options; user_option; user_option = user_option->next) {
|
||||||
|
if (user_option->savefn != NULL) {
|
||||||
|
(*user_option->savefn)(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// $Id: siminterface.h,v 1.221 2009-01-04 21:46:20 vruppert Exp $
|
// $Id: siminterface.h,v 1.222 2009-01-06 20:35:39 vruppert Exp $
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Intro to siminterface by Bryce Denney:
|
// Intro to siminterface by Bryce Denney:
|
||||||
@ -1217,10 +1217,10 @@ public:
|
|||||||
virtual void set_display_mode(disp_mode_t newmode) {}
|
virtual void set_display_mode(disp_mode_t newmode) {}
|
||||||
virtual bx_bool test_for_text_console() {return 1;}
|
virtual bx_bool test_for_text_console() {return 1;}
|
||||||
// user-defined option support
|
// user-defined option support
|
||||||
virtual int find_user_option(const char *keyword) {return -1;}
|
|
||||||
virtual bx_bool register_user_option(const char *keyword, user_option_parser_t parser, user_option_save_t save_func) {return 0;}
|
virtual bx_bool register_user_option(const char *keyword, user_option_parser_t parser, user_option_save_t save_func) {return 0;}
|
||||||
virtual bx_bool unregister_user_option(const char *keyword) {return 0;}
|
virtual bx_bool unregister_user_option(const char *keyword) {return 0;}
|
||||||
virtual Bit32s parse_user_option(int idx, const char *context, int num_params, char *params []) {return -1;}
|
virtual bx_bool is_user_option(const char *keyword) {return 0;}
|
||||||
|
virtual Bit32s parse_user_option(const char *context, int num_params, char *params []) {return -1;}
|
||||||
virtual Bit32s save_user_options(FILE *fp) {return -1;}
|
virtual Bit32s save_user_options(FILE *fp) {return -1;}
|
||||||
// save/restore support
|
// save/restore support
|
||||||
virtual void init_save_restore() {}
|
virtual void init_save_restore() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user