- prepared user-defined config option support

This commit is contained in:
Volker Ruppert 2006-03-29 19:27:31 +00:00
parent a6c3ffeeb5
commit 8d178b107b
3 changed files with 44 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.98 2006-03-13 18:55:52 vruppert Exp $
// $Id: config.cc,v 1.99 2006-03-29 19:27:31 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -3044,6 +3044,11 @@ static Bit32s parse_line_formatted(const char *context, int num_params, char *pa
{
PARSE_ERR(("ERROR: time0 directive is DEPRECATED, use clock: instead"));
}
// user-defined options handled by registered functions
else if (SIM->is_user_option(params[0]))
{
return SIM->parse_user_option(context, num_params, &params[0]);
}
else
{
PARSE_ERR(( "%s: directive '%s' not understood", context, params[0]));

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.cc,v 1.133 2006-03-13 18:55:53 vruppert Exp $
// $Id: siminterface.cc,v 1.134 2006-03-29 19:27:31 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// See siminterface.h for description of the siminterface concept.
@ -14,6 +14,8 @@ logfunctions *siminterface_log = NULL;
bx_list_c *root_param = NULL;
#define LOG_THIS siminterface_log->
#define BX_MAX_USER_OPTIONS 16
// 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
// bx_simulator_interface are implemented; they are all virtual. The
@ -33,6 +35,9 @@ class bx_real_sim_c : public bx_simulator_interface_c {
const char *registered_ci_name;
config_interface_callback_t ci_callback;
void *ci_callback_data;
unsigned n_user_options;
user_option_handler_t user_option_handler[BX_MAX_USER_OPTIONS];
const char *user_option_name[BX_MAX_USER_OPTIONS];
int init_done;
int enabled;
// save context to jump to if we must quit unexpectedly
@ -124,11 +129,15 @@ public:
virtual bool is_wx_selected () { return wxsel; }
// provide interface to bx_gui->set_display_mode() method for config
// interfaces to use.
virtual void set_display_mode (disp_mode_t newmode) {
virtual void set_display_mode(disp_mode_t newmode) {
if (bx_gui != NULL)
bx_gui->set_display_mode (newmode);
bx_gui->set_display_mode(newmode);
}
virtual bool test_for_text_console ();
virtual bool test_for_text_console();
// user-defined option support
virtual bx_bool register_user_option(char *main_param, user_option_handler_t handler);
virtual bx_bool is_user_option(char *main_param);
virtual Bit32s parse_user_option(const char *context, int num_params, char *params []);
};
// recursive function to find parameters from the path
@ -280,6 +289,7 @@ bx_real_sim_c::bx_real_sim_c()
quit_context = NULL;
exit_code = 0;
param_id = BXP_NEW_PARAM_ID;
n_user_options = 0;
}
bx_real_sim_c::~bx_real_sim_c()
@ -774,6 +784,24 @@ bool bx_real_sim_c::test_for_text_console()
return true;
}
bx_bool bx_real_sim_c::register_user_option(char *main_param, user_option_handler_t handler)
{
// TODO
return 0;
}
bx_bool bx_real_sim_c::is_user_option(char *main_param)
{
// TODO
return 0;
}
Bit32s bx_real_sim_c::parse_user_option(const char *context, int num_params, char *params [])
{
// TODO
return -1;
}
/////////////////////////////////////////////////////////////////////////
// define methods of bx_param_* and family

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.179 2006-03-13 18:55:53 vruppert Exp $
// $Id: siminterface.h,v 1.180 2006-03-29 19:27:31 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Intro to siminterface by Bryce Denney:
@ -1047,6 +1047,7 @@ enum ci_return_t {
};
typedef int (*config_interface_callback_t)(void *userdata, ci_command_t command);
typedef BxEvent* (*bxevent_handler)(void *theclass, BxEvent *event);
typedef int (*user_option_handler_t)(const char *context, int num_params, char *params[]);
// bx_gui->set_display_mode() changes the mode between the configuration
// interface and the simulation. This is primarily intended for display
@ -1172,6 +1173,10 @@ public:
// interfaces to use.
virtual void set_display_mode(disp_mode_t newmode) {}
virtual bool test_for_text_console() { return true; }
// user-defined option support
virtual bx_bool register_user_option(char *main_param, user_option_handler_t handler) {return 0;}
virtual bx_bool is_user_option(char *main_param) {return 0;}
virtual Bit32s parse_user_option(const char *context, int num_params, char *params []) {return -1;}
};
BOCHSAPI extern bx_simulator_interface_c *SIM;