2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-03-26 12:19:56 +03:00
|
|
|
// $Id: siminterface.cc,v 1.204 2009-03-26 09:19:56 sshwarts Exp $
|
2009-01-10 14:30:20 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2009 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
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-02-08 12:05:52 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2009-01-10 14:30:20 +03:00
|
|
|
//
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
// See siminterface.h for description of the siminterface concept.
|
|
|
|
// Basically, the siminterface is visible from both the simulator and
|
|
|
|
// the configuration user interface, and allows them to talk to each other.
|
2001-06-08 11:20:07 +04:00
|
|
|
|
2004-06-19 19:20:15 +04:00
|
|
|
#include "iodev.h"
|
2001-06-08 11:20:07 +04:00
|
|
|
|
|
|
|
bx_simulator_interface_c *SIM = NULL;
|
2001-06-11 10:35:18 +04:00
|
|
|
logfunctions *siminterface_log = NULL;
|
2006-02-17 00:44:17 +03:00
|
|
|
bx_list_c *root_param = NULL;
|
2001-06-11 10:35:18 +04:00
|
|
|
#define LOG_THIS siminterface_log->
|
2001-06-08 11:20:07 +04:00
|
|
|
|
2002-04-18 04:22:20 +04:00
|
|
|
// 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
|
|
|
|
// bx_real_sim_c class is a child of bx_simulator_interface_c, and it
|
|
|
|
// implements all the methods. The idea is that a gui needs to know only
|
|
|
|
// definition of bx_simulator_interface to talk to Bochs. The gui should
|
2008-02-06 01:57:43 +03:00
|
|
|
// not need to include bochs.h.
|
2002-04-18 04:22:20 +04:00
|
|
|
//
|
|
|
|
// I made this separation to ensure that all guis use the siminterface to do
|
|
|
|
// access bochs internals, instead of accessing things like
|
|
|
|
// bx_keyboard.s.internal_buffer[4] (or whatever) directly. -Bryce
|
2008-02-06 01:57:43 +03:00
|
|
|
//
|
2002-04-18 04:22:20 +04:00
|
|
|
|
2009-01-06 23:35:39 +03:00
|
|
|
typedef struct _user_option_t {
|
2009-01-06 00:15:17 +03:00
|
|
|
const char *name;
|
|
|
|
user_option_parser_t parser;
|
|
|
|
user_option_save_t savefn;
|
2009-01-06 23:35:39 +03:00
|
|
|
struct _user_option_t *next;
|
2009-01-06 00:15:17 +03:00
|
|
|
} user_option_t;
|
|
|
|
|
2001-06-08 11:20:07 +04:00
|
|
|
class bx_real_sim_c : public bx_simulator_interface_c {
|
2002-10-25 01:07:56 +04:00
|
|
|
bxevent_handler bxevent_callback;
|
|
|
|
void *bxevent_callback_data;
|
|
|
|
const char *registered_ci_name;
|
|
|
|
config_interface_callback_t ci_callback;
|
|
|
|
void *ci_callback_data;
|
2009-01-06 23:35:39 +03:00
|
|
|
user_option_t *user_options;
|
2001-06-18 18:11:55 +04:00
|
|
|
int init_done;
|
2001-06-22 01:24:05 +04:00
|
|
|
int enabled;
|
- use setjmp() and longjmp() to quit the simulation thread cleanly.
I use setjmp() to save the context just before calling
bx_continue_after_config_interface(). Then, in
bx_real_sim_c:quit_sim, I use longjmp() to jump back to that context.
This happens in main.cc and in gui/wxmain.cc (wxWindows only).
I haven't tested with the debugger yet. Possibly with debugger
the quit longjmp() should jump back to the debugger prompt loop
instead of actually quitting the program.
- clean up BX_ASYNC_EVT_LOG_MSG implementation by creating a different,
synchronous event called BX_SYNC_EVT_LOG_ASK. The async event
could be used to simply tell the CI that an event has occurred,
for example if the user wanted to view the events on screen
(not implemented). The sync event is used when you want the user
to respond before the simulation can continue, such as a for the
"panic=ask" behavior.
- in wxmain.cc, move the updates to the Start,Stop,Pause,Resume menu
items into a separate method simStatusChanged(). This makes the code that
does important stuff more readable.
- remove wxMutexGuiEnter()/Leave() from MyFrame::OnSim2CuiEvent().
This method is an event handler called in the gui thread, so it
already has the gui lock. This call caused thread lock on my linux
box.
2002-08-27 22:11:13 +04:00
|
|
|
// save context to jump to if we must quit unexpectedly
|
|
|
|
jmp_buf *quit_context;
|
2002-12-16 09:43:02 +03:00
|
|
|
int exit_code;
|
2006-02-19 18:43:03 +03:00
|
|
|
unsigned param_id;
|
2001-06-11 18:03:35 +04:00
|
|
|
public:
|
2006-03-08 21:10:41 +03:00
|
|
|
bx_real_sim_c();
|
2006-05-30 02:33:38 +04:00
|
|
|
virtual ~bx_real_sim_c() {}
|
2006-03-08 21:10:41 +03:00
|
|
|
virtual void set_quit_context(jmp_buf *context) { quit_context = context; }
|
|
|
|
virtual int get_init_done() { return init_done; }
|
|
|
|
virtual int set_init_done(int n) { init_done = n; return 0;}
|
2006-03-05 13:24:29 +03:00
|
|
|
virtual void reset_all_param();
|
2006-02-19 18:43:03 +03:00
|
|
|
// new param methods
|
2006-02-18 19:53:18 +03:00
|
|
|
virtual bx_param_c *get_param(const char *pname, bx_param_c *base=NULL);
|
2006-02-26 22:11:20 +03:00
|
|
|
virtual bx_param_num_c *get_param_num(const char *pname, bx_param_c *base=NULL);
|
|
|
|
virtual bx_param_string_c *get_param_string(const char *pname, bx_param_c *base=NULL);
|
|
|
|
virtual bx_param_bool_c *get_param_bool(const char *pname, bx_param_c *base=NULL);
|
|
|
|
virtual bx_param_enum_c *get_param_enum(const char *pname, bx_param_c *base=NULL);
|
2007-10-14 23:04:51 +04:00
|
|
|
virtual Bit32u gen_param_id() { return param_id++; }
|
2006-03-05 13:24:29 +03:00
|
|
|
virtual int get_n_log_modules();
|
|
|
|
virtual char *get_prefix(int mod);
|
|
|
|
virtual int get_log_action(int mod, int level);
|
|
|
|
virtual void set_log_action(int mod, int level, int action);
|
|
|
|
virtual char *get_action_name(int action);
|
|
|
|
virtual int get_default_log_action(int level) {
|
|
|
|
return logfunctions::get_default_action(level);
|
- How to handle default log options has been somewhat confused for a long
time, so I've tried to improve it. Now the logfunctions class has a
static field default_onoff[] which represents the default actions for
each kind of log message. Default_onoff[] is initialized with static
data so it should be valid by the time it's used. This can be reached by
static accesors logfunctions::set_default_action and
logfunctions::get_default_action. It seemed appropriate to put the defaults
inside the logfunctions class, rather than in bx_options or siminterface.
However, to make them accessible to the config interface, I added similar
methods in siminterface that map to the accessors in logfunctions.
- logio.cc had two different definitions of LOG_THIS for different halves
of the file, which was ugly and confusing. (LOG_THIS is needed for BX_INFO,
BX_DEBUG, etc.) I removed the first definition and fixed the minor compile
problems that ensued. In the initializers for iofunctions, everything
is complicated because of the unpredictable order that constructors get
called. They must use this->log to print things, because genlog hasn't
been initialized yet.
- now if SIM->set_log_action(int mod, int level, int action) is called
with mod<0, it sets the action for all modules/devices instead of just one.
- modified: bochs.h logio.cc main.cc gui/siminterface.cc gui/siminterface.h
2002-09-20 21:56:22 +04:00
|
|
|
}
|
2006-03-05 13:24:29 +03:00
|
|
|
virtual void set_default_log_action(int level, int action) {
|
|
|
|
logfunctions::set_default_action(level, action);
|
- How to handle default log options has been somewhat confused for a long
time, so I've tried to improve it. Now the logfunctions class has a
static field default_onoff[] which represents the default actions for
each kind of log message. Default_onoff[] is initialized with static
data so it should be valid by the time it's used. This can be reached by
static accesors logfunctions::set_default_action and
logfunctions::get_default_action. It seemed appropriate to put the defaults
inside the logfunctions class, rather than in bx_options or siminterface.
However, to make them accessible to the config interface, I added similar
methods in siminterface that map to the accessors in logfunctions.
- logio.cc had two different definitions of LOG_THIS for different halves
of the file, which was ugly and confusing. (LOG_THIS is needed for BX_INFO,
BX_DEBUG, etc.) I removed the first definition and fixed the minor compile
problems that ensued. In the initializers for iofunctions, everything
is complicated because of the unpredictable order that constructors get
called. They must use this->log to print things, because genlog hasn't
been initialized yet.
- now if SIM->set_log_action(int mod, int level, int action) is called
with mod<0, it sets the action for all modules/devices instead of just one.
- modified: bochs.h logio.cc main.cc gui/siminterface.cc gui/siminterface.h
2002-09-20 21:56:22 +04:00
|
|
|
}
|
2006-03-05 13:24:29 +03:00
|
|
|
virtual const char *get_log_level_name(int level);
|
2007-10-14 23:04:51 +04:00
|
|
|
virtual int get_max_log_level() { return N_LOGLEV; }
|
2006-03-05 13:24:29 +03:00
|
|
|
virtual void quit_sim(int code);
|
|
|
|
virtual int get_exit_code() { return exit_code; }
|
|
|
|
virtual int get_default_rc(char *path, int len);
|
2006-03-13 21:55:53 +03:00
|
|
|
virtual int read_rc(const char *path);
|
|
|
|
virtual int write_rc(const char *path, int overwrite);
|
2006-03-05 13:24:29 +03:00
|
|
|
virtual int get_log_file(char *path, int len);
|
|
|
|
virtual int set_log_file(char *path);
|
|
|
|
virtual int get_log_prefix(char *prefix, int len);
|
|
|
|
virtual int set_log_prefix(char *prefix);
|
|
|
|
virtual int get_debugger_log_file(char *path, int len);
|
|
|
|
virtual int set_debugger_log_file(char *path);
|
2006-02-26 22:11:20 +03:00
|
|
|
virtual int get_cdrom_options(int drive, bx_list_c **out, int *device = NULL);
|
2006-03-05 13:24:29 +03:00
|
|
|
virtual void set_notify_callback(bxevent_handler func, void *arg);
|
|
|
|
virtual void get_notify_callback(bxevent_handler *func, void **arg);
|
|
|
|
virtual BxEvent* sim_to_ci_event(BxEvent *event);
|
|
|
|
virtual int log_msg(const char *prefix, int level, const char *msg);
|
2006-02-27 12:37:58 +03:00
|
|
|
virtual int ask_param(bx_param_c *param);
|
2006-02-22 22:18:29 +03:00
|
|
|
virtual int ask_param(const char *pname);
|
2002-04-18 04:22:20 +04:00
|
|
|
// ask the user for a pathname
|
2007-10-25 03:09:59 +04:00
|
|
|
virtual int ask_filename(const char *filename, int maxlen, const char *prompt, const char *the_default, int flags);
|
2006-06-01 00:12:43 +04:00
|
|
|
// yes/no dialog
|
2007-10-25 03:09:59 +04:00
|
|
|
virtual int ask_yes_no(const char *title, const char *prompt, bx_bool the_default);
|
2002-04-18 04:22:20 +04:00
|
|
|
// called at a regular interval, currently by the keyboard handler.
|
2008-12-28 23:30:48 +03:00
|
|
|
virtual void periodic();
|
|
|
|
virtual int create_disk_image(const char *filename, int sectors, bx_bool overwrite);
|
|
|
|
virtual void refresh_ci();
|
|
|
|
virtual void refresh_vga() {
|
2002-09-23 21:41:42 +04:00
|
|
|
// maybe need to check if something has been initialized yet?
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_vga_refresh();
|
2002-09-23 21:41:42 +04:00
|
|
|
}
|
2008-12-28 23:30:48 +03:00
|
|
|
virtual void handle_events() {
|
2002-09-23 21:41:42 +04:00
|
|
|
// maybe need to check if something has been initialized yet?
|
2008-12-28 23:30:48 +03:00
|
|
|
bx_gui->handle_events();
|
2002-09-23 21:41:42 +04:00
|
|
|
}
|
2002-12-07 22:43:53 +03:00
|
|
|
// find first hard drive or cdrom
|
2006-02-26 22:11:20 +03:00
|
|
|
bx_param_c *get_first_atadevice(Bit32u search_type);
|
|
|
|
bx_param_c *get_first_cdrom() {
|
|
|
|
return get_first_atadevice(BX_ATA_DEVICE_CDROM);
|
2002-12-07 22:43:53 +03:00
|
|
|
}
|
2006-02-26 22:11:20 +03:00
|
|
|
bx_param_c *get_first_hd() {
|
|
|
|
return get_first_atadevice(BX_ATA_DEVICE_DISK);
|
2002-12-07 22:43:53 +03:00
|
|
|
}
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
#if BX_DEBUGGER
|
2008-12-28 23:30:48 +03:00
|
|
|
virtual void debug_break();
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
virtual void debug_interpret_cmd (char *cmd);
|
|
|
|
virtual char *debug_get_next_command ();
|
2008-12-28 23:30:48 +03:00
|
|
|
virtual void debug_puts(const char *cmd);
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
#endif
|
2002-10-25 01:07:56 +04:00
|
|
|
virtual void register_configuration_interface (
|
2008-02-06 01:57:43 +03:00
|
|
|
const char* name,
|
2002-10-25 01:07:56 +04:00
|
|
|
config_interface_callback_t callback,
|
|
|
|
void *userdata);
|
|
|
|
virtual int configuration_interface(const char* name, ci_command_t command);
|
2008-12-28 23:30:48 +03:00
|
|
|
virtual int begin_simulation(int argc, char *argv[]);
|
2006-04-07 00:42:51 +04:00
|
|
|
virtual void set_sim_thread_func(is_sim_thread_func_t func) {}
|
|
|
|
virtual bx_bool is_sim_thread();
|
2006-11-12 13:07:18 +03:00
|
|
|
bx_bool debug_gui;
|
|
|
|
virtual void set_debug_gui(bx_bool val) { debug_gui = val; }
|
|
|
|
virtual bx_bool has_debug_gui() { return debug_gui; }
|
2002-12-06 22:34:32 +03:00
|
|
|
// provide interface to bx_gui->set_display_mode() method for config
|
|
|
|
// interfaces to use.
|
2006-03-29 23:27:31 +04:00
|
|
|
virtual void set_display_mode(disp_mode_t newmode) {
|
2002-12-06 22:34:32 +03:00
|
|
|
if (bx_gui != NULL)
|
2006-03-29 23:27:31 +04:00
|
|
|
bx_gui->set_display_mode(newmode);
|
2002-12-06 22:34:32 +03:00
|
|
|
}
|
2006-04-07 00:42:51 +04:00
|
|
|
virtual bx_bool test_for_text_console();
|
2006-03-29 23:27:31 +04:00
|
|
|
// user-defined option support
|
2006-04-14 12:07:24 +04:00
|
|
|
virtual bx_bool register_user_option(const char *keyword, user_option_parser_t parser, user_option_save_t save_func);
|
2009-01-05 00:46:20 +03:00
|
|
|
virtual bx_bool unregister_user_option(const char *keyword);
|
2009-01-06 23:35:39 +03:00
|
|
|
virtual bx_bool is_user_option(const char *keyword);
|
|
|
|
virtual Bit32s parse_user_option(const char *context, int num_params, char *params []);
|
2006-04-14 12:07:24 +04:00
|
|
|
virtual Bit32s save_user_options(FILE *fp);
|
2007-09-28 23:52:08 +04:00
|
|
|
|
2006-04-07 00:42:51 +04:00
|
|
|
// save/restore support
|
2006-09-07 22:50:51 +04:00
|
|
|
virtual void init_save_restore();
|
2006-04-07 16:49:50 +04:00
|
|
|
virtual bx_bool save_state(const char *checkpoint_path);
|
2006-04-07 00:42:51 +04:00
|
|
|
virtual bx_bool restore_config();
|
|
|
|
virtual bx_bool restore_logopts();
|
|
|
|
virtual bx_bool restore_hardware();
|
2007-09-28 23:52:08 +04:00
|
|
|
virtual bx_list_c *get_bochs_root() {
|
|
|
|
return (bx_list_c*)get_param("bochs", NULL);
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
2007-10-14 23:04:51 +04:00
|
|
|
virtual bx_bool restore_bochs_param(bx_list_c *root, const char *sr_path, const char *restore_name);
|
|
|
|
|
2006-04-15 18:05:18 +04:00
|
|
|
private:
|
2007-10-14 04:20:30 +04:00
|
|
|
bx_bool save_sr_param(FILE *fp, bx_param_c *node, const char *sr_path, int level);
|
2001-06-08 11:20:07 +04:00
|
|
|
};
|
|
|
|
|
2009-01-31 13:04:25 +03:00
|
|
|
#if BX_DEBUGGER && BX_DEBUGGER_GUI
|
|
|
|
// FIXME: these probably belong inside the bx_simulator_interface_c structure
|
2009-01-12 22:15:35 +03:00
|
|
|
char *debug_cmd = NULL;
|
|
|
|
bx_bool debug_cmd_ready = 0;
|
|
|
|
bx_bool vgaw_refresh = 0;
|
|
|
|
#endif
|
|
|
|
|
2006-02-17 00:44:17 +03:00
|
|
|
// recursive function to find parameters from the path
|
2006-03-07 01:03:16 +03:00
|
|
|
static bx_param_c *find_param(const char *full_pname, const char *rest_of_pname, bx_param_c *base)
|
2006-02-17 00:44:17 +03:00
|
|
|
{
|
|
|
|
const char *from = rest_of_pname;
|
|
|
|
char component[BX_PATHNAME_LEN];
|
|
|
|
char *to = component;
|
|
|
|
// copy the first piece of pname into component, stopping at first separator
|
|
|
|
// or at the end of the string
|
|
|
|
while (*from != 0 && *from != '.') {
|
|
|
|
*to = *from;
|
|
|
|
to++;
|
|
|
|
from++;
|
|
|
|
}
|
|
|
|
*to = 0;
|
|
|
|
if (!component[0]) {
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_PANIC(("find_param: found empty component in parameter name '%s'", full_pname));
|
2006-02-17 00:44:17 +03:00
|
|
|
// or does that mean that we're done?
|
|
|
|
}
|
|
|
|
if (base->get_type() != BXT_LIST) {
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_PANIC(("find_param: base was not a list!"));
|
2006-02-17 00:44:17 +03:00
|
|
|
}
|
|
|
|
BX_DEBUG(("searching for component '%s' in list '%s'", component, base->get_name()));
|
|
|
|
|
|
|
|
// find the component in the list.
|
|
|
|
bx_list_c *list = (bx_list_c *)base;
|
2006-03-05 13:24:29 +03:00
|
|
|
bx_param_c *child = list->get_by_name(component);
|
2006-02-17 00:44:17 +03:00
|
|
|
// if child not found, there is nothing else that can be done. return NULL.
|
|
|
|
if (child == NULL) return NULL;
|
|
|
|
if (from[0] == 0) {
|
|
|
|
// that was the end of the path, we're done
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
// continue parsing the path
|
|
|
|
BX_ASSERT(from[0] == '.');
|
|
|
|
from++; // skip over the separator
|
2006-03-05 13:24:29 +03:00
|
|
|
return find_param(full_pname, from, child);
|
2006-02-17 00:44:17 +03:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:57:43 +03:00
|
|
|
bx_param_c *bx_real_sim_c::get_param(const char *pname, bx_param_c *base)
|
2006-02-17 00:44:17 +03:00
|
|
|
{
|
|
|
|
if (base == NULL)
|
|
|
|
base = root_param;
|
|
|
|
// to access top level object, look for parameter "."
|
|
|
|
if (pname[0] == '.' && pname[1] == 0)
|
|
|
|
return base;
|
2006-02-26 22:11:20 +03:00
|
|
|
return find_param(pname, pname, base);
|
2006-02-17 00:44:17 +03:00
|
|
|
}
|
|
|
|
|
2008-12-28 23:30:48 +03:00
|
|
|
bx_param_num_c *bx_real_sim_c::get_param_num(const char *pname, bx_param_c *base)
|
2006-05-30 02:33:38 +04:00
|
|
|
{
|
2009-03-26 12:19:56 +03:00
|
|
|
bx_param_c *gen = get_param(pname, base);
|
|
|
|
if (gen==NULL) {
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_ERROR(("get_param_num(%s) could not find a parameter", pname));
|
2006-02-17 00:44:17 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-03-26 12:19:56 +03:00
|
|
|
int type = gen->get_type();
|
2006-02-17 00:44:17 +03:00
|
|
|
if (type == BXT_PARAM_NUM || type == BXT_PARAM_BOOL || type == BXT_PARAM_ENUM)
|
2009-03-26 12:19:56 +03:00
|
|
|
return (bx_param_num_c *)gen;
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_ERROR(("get_param_num(%s) could not find an integer parameter with that name", pname));
|
2006-02-17 00:44:17 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-30 02:33:38 +04:00
|
|
|
bx_param_string_c *bx_real_sim_c::get_param_string(const char *pname, bx_param_c *base)
|
|
|
|
{
|
2009-03-26 12:19:56 +03:00
|
|
|
bx_param_c *gen = get_param(pname, base);
|
|
|
|
if (gen==NULL) {
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_ERROR(("get_param_string(%s) could not find a parameter", pname));
|
2006-02-17 00:44:17 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-03-26 12:19:56 +03:00
|
|
|
if (gen->get_type() == BXT_PARAM_STRING)
|
|
|
|
return (bx_param_string_c *)gen;
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_ERROR(("get_param_string(%s) could not find an integer parameter with that name", pname));
|
2006-02-17 00:44:17 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-30 02:33:38 +04:00
|
|
|
bx_param_bool_c *bx_real_sim_c::get_param_bool(const char *pname, bx_param_c *base)
|
|
|
|
{
|
2009-03-26 12:19:56 +03:00
|
|
|
bx_param_c *gen = get_param(pname, base);
|
|
|
|
if (gen==NULL) {
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_ERROR(("get_param_bool(%s) could not find a parameter", pname));
|
2006-02-17 00:44:17 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-03-26 12:19:56 +03:00
|
|
|
if (gen->get_type () == BXT_PARAM_BOOL)
|
|
|
|
return (bx_param_bool_c *)gen;
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_ERROR(("get_param_bool(%s) could not find a bool parameter with that name", pname));
|
2006-02-17 00:44:17 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-30 02:33:38 +04:00
|
|
|
bx_param_enum_c *bx_real_sim_c::get_param_enum(const char *pname, bx_param_c *base)
|
|
|
|
{
|
2009-03-26 12:19:56 +03:00
|
|
|
bx_param_c *gen = get_param(pname, base);
|
|
|
|
if (gen==NULL) {
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_ERROR(("get_param_enum(%s) could not find a parameter", pname));
|
2006-02-17 00:44:17 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-03-26 12:19:56 +03:00
|
|
|
if (gen->get_type() == BXT_PARAM_ENUM)
|
|
|
|
return (bx_param_enum_c *)gen;
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_ERROR(("get_param_enum(%s) could not find a enum parameter with that name", pname));
|
2006-02-17 00:44:17 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-03-06 21:50:55 +03:00
|
|
|
void bx_init_siminterface()
|
2001-06-08 11:20:07 +04:00
|
|
|
{
|
2006-03-06 21:50:55 +03:00
|
|
|
siminterface_log = new logfunctions();
|
|
|
|
siminterface_log->put("CTRL");
|
2008-02-06 01:57:43 +03:00
|
|
|
if (SIM == NULL)
|
2001-06-08 11:20:07 +04:00
|
|
|
SIM = new bx_real_sim_c();
|
2006-02-17 00:44:17 +03:00
|
|
|
if (root_param == NULL) {
|
2006-03-06 21:50:55 +03:00
|
|
|
root_param = new bx_list_c(NULL,
|
2006-03-07 20:54:27 +03:00
|
|
|
"bochs",
|
2008-02-06 01:57:43 +03:00
|
|
|
"list of top level bochs parameters",
|
2006-03-07 20:54:27 +03:00
|
|
|
30);
|
2006-02-17 00:44:17 +03:00
|
|
|
}
|
2001-06-08 11:20:07 +04:00
|
|
|
}
|
|
|
|
|
2006-03-06 21:50:55 +03:00
|
|
|
bx_real_sim_c::bx_real_sim_c()
|
2001-06-11 18:03:35 +04:00
|
|
|
{
|
2002-10-25 01:07:56 +04:00
|
|
|
bxevent_callback = NULL;
|
|
|
|
bxevent_callback_data = NULL;
|
|
|
|
ci_callback = NULL;
|
|
|
|
ci_callback_data = NULL;
|
|
|
|
is_sim_thread_func = NULL;
|
2006-11-12 13:07:18 +03:00
|
|
|
debug_gui = 0;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2002-04-18 04:22:20 +04:00
|
|
|
enabled = 1;
|
2001-06-19 08:55:01 +04:00
|
|
|
init_done = 0;
|
- use setjmp() and longjmp() to quit the simulation thread cleanly.
I use setjmp() to save the context just before calling
bx_continue_after_config_interface(). Then, in
bx_real_sim_c:quit_sim, I use longjmp() to jump back to that context.
This happens in main.cc and in gui/wxmain.cc (wxWindows only).
I haven't tested with the debugger yet. Possibly with debugger
the quit longjmp() should jump back to the debugger prompt loop
instead of actually quitting the program.
- clean up BX_ASYNC_EVT_LOG_MSG implementation by creating a different,
synchronous event called BX_SYNC_EVT_LOG_ASK. The async event
could be used to simply tell the CI that an event has occurred,
for example if the user wanted to view the events on screen
(not implemented). The sync event is used when you want the user
to respond before the simulation can continue, such as a for the
"panic=ask" behavior.
- in wxmain.cc, move the updates to the Start,Stop,Pause,Resume menu
items into a separate method simStatusChanged(). This makes the code that
does important stuff more readable.
- remove wxMutexGuiEnter()/Leave() from MyFrame::OnSim2CuiEvent().
This method is an event handler called in the gui thread, so it
already has the gui lock. This call caused thread lock on my linux
box.
2002-08-27 22:11:13 +04:00
|
|
|
quit_context = NULL;
|
2002-12-16 09:43:02 +03:00
|
|
|
exit_code = 0;
|
2006-02-19 18:43:03 +03:00
|
|
|
param_id = BXP_NEW_PARAM_ID;
|
2009-01-06 23:35:39 +03:00
|
|
|
user_options = NULL;
|
2001-06-18 18:11:55 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
void bx_real_sim_c::reset_all_param()
|
2002-08-30 20:23:36 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
bx_reset_options();
|
2002-08-30 20:23:36 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
int bx_real_sim_c::get_n_log_modules()
|
2001-06-08 11:20:07 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
return io->get_n_logfns();
|
2001-06-08 11:20:07 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
char *bx_real_sim_c::get_prefix(int mod)
|
2001-06-08 11:20:07 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
logfunc_t *logfn = io->get_logfn(mod);
|
|
|
|
return logfn->getprefix();
|
2001-06-08 11:20:07 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
int bx_real_sim_c::get_log_action(int mod, int level)
|
2001-06-08 11:20:07 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
logfunc_t *logfn = io->get_logfn(mod);
|
|
|
|
return logfn->getonoff(level);
|
2001-06-08 11:20:07 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
void bx_real_sim_c::set_log_action(int mod, int level, int action)
|
2001-06-08 11:20:07 +04:00
|
|
|
{
|
- How to handle default log options has been somewhat confused for a long
time, so I've tried to improve it. Now the logfunctions class has a
static field default_onoff[] which represents the default actions for
each kind of log message. Default_onoff[] is initialized with static
data so it should be valid by the time it's used. This can be reached by
static accesors logfunctions::set_default_action and
logfunctions::get_default_action. It seemed appropriate to put the defaults
inside the logfunctions class, rather than in bx_options or siminterface.
However, to make them accessible to the config interface, I added similar
methods in siminterface that map to the accessors in logfunctions.
- logio.cc had two different definitions of LOG_THIS for different halves
of the file, which was ugly and confusing. (LOG_THIS is needed for BX_INFO,
BX_DEBUG, etc.) I removed the first definition and fixed the minor compile
problems that ensued. In the initializers for iofunctions, everything
is complicated because of the unpredictable order that constructors get
called. They must use this->log to print things, because genlog hasn't
been initialized yet.
- now if SIM->set_log_action(int mod, int level, int action) is called
with mod<0, it sets the action for all modules/devices instead of just one.
- modified: bochs.h logio.cc main.cc gui/siminterface.cc gui/siminterface.h
2002-09-20 21:56:22 +04:00
|
|
|
// normal
|
|
|
|
if (mod >= 0) {
|
2006-03-07 20:54:27 +03:00
|
|
|
logfunc_t *logfn = io->get_logfn(mod);
|
|
|
|
logfn->setonoff(level, action);
|
|
|
|
return;
|
- How to handle default log options has been somewhat confused for a long
time, so I've tried to improve it. Now the logfunctions class has a
static field default_onoff[] which represents the default actions for
each kind of log message. Default_onoff[] is initialized with static
data so it should be valid by the time it's used. This can be reached by
static accesors logfunctions::set_default_action and
logfunctions::get_default_action. It seemed appropriate to put the defaults
inside the logfunctions class, rather than in bx_options or siminterface.
However, to make them accessible to the config interface, I added similar
methods in siminterface that map to the accessors in logfunctions.
- logio.cc had two different definitions of LOG_THIS for different halves
of the file, which was ugly and confusing. (LOG_THIS is needed for BX_INFO,
BX_DEBUG, etc.) I removed the first definition and fixed the minor compile
problems that ensued. In the initializers for iofunctions, everything
is complicated because of the unpredictable order that constructors get
called. They must use this->log to print things, because genlog hasn't
been initialized yet.
- now if SIM->set_log_action(int mod, int level, int action) is called
with mod<0, it sets the action for all modules/devices instead of just one.
- modified: bochs.h logio.cc main.cc gui/siminterface.cc gui/siminterface.h
2002-09-20 21:56:22 +04:00
|
|
|
}
|
|
|
|
// if called with mod<0 loop over all
|
|
|
|
int nmod = get_n_log_modules ();
|
|
|
|
for (mod=0; mod<nmod; mod++)
|
2006-03-07 20:54:27 +03:00
|
|
|
set_log_action(mod, level, action);
|
2001-06-08 11:20:07 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
char *bx_real_sim_c::get_action_name(int action)
|
2001-06-08 11:20:07 +04:00
|
|
|
{
|
2006-03-07 01:03:16 +03:00
|
|
|
return io->getaction(action);
|
2001-06-08 11:20:07 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
const char *bx_real_sim_c::get_log_level_name(int level)
|
2001-06-08 11:20:07 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
return io->getlevel(level);
|
2001-06-08 11:20:07 +04:00
|
|
|
}
|
|
|
|
|
2008-09-20 01:31:08 +04:00
|
|
|
void bx_real_sim_c::quit_sim(int code)
|
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
BX_INFO(("quit_sim called with exit code %d", code));
|
2002-12-16 09:43:02 +03:00
|
|
|
exit_code = code;
|
2006-09-09 15:28:52 +04:00
|
|
|
io->exit_log();
|
- use setjmp() and longjmp() to quit the simulation thread cleanly.
I use setjmp() to save the context just before calling
bx_continue_after_config_interface(). Then, in
bx_real_sim_c:quit_sim, I use longjmp() to jump back to that context.
This happens in main.cc and in gui/wxmain.cc (wxWindows only).
I haven't tested with the debugger yet. Possibly with debugger
the quit longjmp() should jump back to the debugger prompt loop
instead of actually quitting the program.
- clean up BX_ASYNC_EVT_LOG_MSG implementation by creating a different,
synchronous event called BX_SYNC_EVT_LOG_ASK. The async event
could be used to simply tell the CI that an event has occurred,
for example if the user wanted to view the events on screen
(not implemented). The sync event is used when you want the user
to respond before the simulation can continue, such as a for the
"panic=ask" behavior.
- in wxmain.cc, move the updates to the Start,Stop,Pause,Resume menu
items into a separate method simStatusChanged(). This makes the code that
does important stuff more readable.
- remove wxMutexGuiEnter()/Leave() from MyFrame::OnSim2CuiEvent().
This method is an event handler called in the gui thread, so it
already has the gui lock. This call caused thread lock on my linux
box.
2002-08-27 22:11:13 +04:00
|
|
|
// use longjmp to quit cleanly, no matter where in the stack we are.
|
2002-09-07 18:27:50 +04:00
|
|
|
if (quit_context != NULL) {
|
2006-03-07 20:54:27 +03:00
|
|
|
longjmp(*quit_context, 1);
|
|
|
|
BX_PANIC(("in bx_real_sim_c::quit_sim, longjmp should never return"));
|
2002-11-19 12:27:39 +03:00
|
|
|
} else {
|
2006-09-07 22:50:51 +04:00
|
|
|
// use exit() to stop the application.
|
2002-11-19 12:27:39 +03:00
|
|
|
if (!code)
|
2006-03-07 20:54:27 +03:00
|
|
|
BX_PANIC(("Quit simulation command"));
|
2006-03-12 01:40:32 +03:00
|
|
|
::exit(exit_code);
|
2002-11-19 12:27:39 +03:00
|
|
|
}
|
2001-06-08 11:20:07 +04:00
|
|
|
}
|
2001-06-10 00:01:12 +04:00
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
int bx_real_sim_c::get_default_rc(char *path, int len)
|
2001-06-10 00:01:12 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
char *rc = bx_find_bochsrc();
|
2001-06-10 00:01:12 +04:00
|
|
|
if (rc == NULL) return -1;
|
2006-03-07 20:54:27 +03:00
|
|
|
strncpy(path, rc, len);
|
2002-10-14 17:31:25 +04:00
|
|
|
path[len-1] = 0;
|
2001-06-10 00:01:12 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-13 21:55:53 +03:00
|
|
|
int bx_real_sim_c::read_rc(const char *rc)
|
2001-06-10 00:01:12 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
return bx_read_configuration(rc);
|
2001-06-10 00:01:12 +04:00
|
|
|
}
|
|
|
|
|
2001-06-11 10:35:18 +04:00
|
|
|
// return values:
|
|
|
|
// 0: written ok
|
|
|
|
// -1: failed
|
|
|
|
// -2: already exists, and overwrite was off
|
2006-03-13 21:55:53 +03:00
|
|
|
int bx_real_sim_c::write_rc(const char *rc, int overwrite)
|
2001-06-11 10:35:18 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
return bx_write_configuration(rc, overwrite);
|
2001-06-11 10:35:18 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::get_log_file(char *path, int len)
|
2001-06-10 00:01:12 +04:00
|
|
|
{
|
2006-03-05 13:24:29 +03:00
|
|
|
strncpy(path, SIM->get_param_string(BXPN_LOG_FILENAME)->getptr(), len);
|
2001-06-10 00:01:12 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::set_log_file(char *path)
|
2001-06-10 00:01:12 +04:00
|
|
|
{
|
2006-03-05 13:24:29 +03:00
|
|
|
SIM->get_param_string(BXPN_LOG_FILENAME)->set(path);
|
2001-06-10 00:01:12 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::get_log_prefix(char *prefix, int len)
|
2002-06-26 18:42:35 +04:00
|
|
|
{
|
2006-03-05 13:24:29 +03:00
|
|
|
strncpy(prefix, SIM->get_param_string(BXPN_LOG_PREFIX)->getptr(), len);
|
2002-06-26 18:42:35 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::set_log_prefix(char *prefix)
|
2002-06-26 18:42:35 +04:00
|
|
|
{
|
2006-03-05 13:24:29 +03:00
|
|
|
SIM->get_param_string(BXPN_LOG_PREFIX)->set(prefix);
|
2002-06-26 18:42:35 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::get_debugger_log_file(char *path, int len)
|
2002-12-03 00:26:05 +03:00
|
|
|
{
|
2006-03-05 13:24:29 +03:00
|
|
|
strncpy(path, SIM->get_param_string(BXPN_DEBUGGER_LOG_FILENAME)->getptr(), len);
|
2002-12-03 00:26:05 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::set_debugger_log_file(char *path)
|
2002-12-03 00:26:05 +03:00
|
|
|
{
|
2006-03-05 13:24:29 +03:00
|
|
|
SIM->get_param_string(BXPN_DEBUGGER_LOG_FILENAME)->set(path);
|
2002-12-03 00:26:05 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::get_cdrom_options(int level, bx_list_c **out, int *where)
|
2002-09-23 00:56:12 +04:00
|
|
|
{
|
2006-02-26 22:11:20 +03:00
|
|
|
char pname[80];
|
|
|
|
|
2002-09-23 00:56:12 +04:00
|
|
|
for (Bit8u channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
|
|
|
|
for (Bit8u device=0; device<2; device++) {
|
2006-02-26 22:11:20 +03:00
|
|
|
sprintf(pname, "ata.%d.%s", channel, (device==0)?"master":"slave");
|
2007-10-14 04:20:30 +04:00
|
|
|
bx_list_c *devlist = (bx_list_c*) SIM->get_param(pname);
|
2006-02-26 22:11:20 +03:00
|
|
|
if (SIM->get_param_enum("type", devlist)->get() == BX_ATA_DEVICE_CDROM) {
|
2002-09-23 00:56:12 +04:00
|
|
|
if (level==0) {
|
2006-02-26 22:11:20 +03:00
|
|
|
*out = devlist;
|
|
|
|
if (where != NULL) *where = (channel * 2) + device;
|
2002-09-23 00:56:12 +04:00
|
|
|
return 1;
|
2006-02-26 22:11:20 +03:00
|
|
|
} else {
|
|
|
|
level--;
|
|
|
|
}
|
2002-09-23 00:56:12 +04:00
|
|
|
}
|
|
|
|
}
|
2006-02-26 22:11:20 +03:00
|
|
|
}
|
2001-06-12 00:51:15 +04:00
|
|
|
return 0;
|
2001-06-10 00:01:12 +04:00
|
|
|
}
|
|
|
|
|
2007-10-25 03:09:59 +04:00
|
|
|
const char *bochs_start_names[] = { "quick", "load", "edit", "run" };
|
2003-02-07 02:16:56 +03:00
|
|
|
|
2009-03-23 22:05:16 +03:00
|
|
|
const char *floppy_devtype_names[] = { "none", "5.25\" 360K", "5.25\" 1.2M", "3.5\" 720K", "3.5\" 1.44M", "3.5\" 2.88M", NULL };
|
2007-10-25 03:09:59 +04:00
|
|
|
const char *floppy_type_names[] = { "none", "1.2M", "1.44M", "2.88M", "720K", "360K", "160K", "180K", "320K", "auto", NULL };
|
2005-11-20 20:22:44 +03:00
|
|
|
int floppy_type_n_sectors[] = { -1, 80*2*15, 80*2*18, 80*2*36, 80*2*9, 40*2*9, 40*1*8, 40*1*9, 40*2*8, -1 };
|
2006-12-17 11:17:28 +03:00
|
|
|
|
2007-10-25 03:09:59 +04:00
|
|
|
const char *bochs_bootdisk_names[] = { "none", "floppy", "disk","cdrom", "network", NULL };
|
|
|
|
const char *loader_os_names[] = { "none", "linux", "nullkernel", NULL };
|
|
|
|
const char *keyboard_type_names[] = { "xt", "at", "mf", NULL };
|
2003-05-03 20:37:18 +04:00
|
|
|
|
2007-10-25 03:09:59 +04:00
|
|
|
const char *atadevice_type_names[] = { "disk", "cdrom", NULL };
|
|
|
|
//const char *atadevice_mode_names[] = { "flat", "concat", "external", "dll", "sparse", "vmware3", "vmware4", "undoable", "growing", "volatile", "z-undoable", "z-volatile", NULL };
|
|
|
|
const char *atadevice_mode_names[] = { "flat", "concat", "external", "dll", "sparse", "vmware3", "vmware4", "undoable", "growing", "volatile", NULL };
|
|
|
|
const char *atadevice_biosdetect_names[] = { "none", "auto", "cmos", NULL };
|
|
|
|
const char *atadevice_translation_names[] = { "none", "lba", "large", "rechs", "auto", NULL };
|
|
|
|
const char *clock_sync_names[] = { "none", "realtime", "slowdown", "both", NULL };
|
2003-08-19 04:10:39 +04:00
|
|
|
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
void bx_real_sim_c::set_notify_callback(bxevent_handler func, void *arg)
|
2001-06-11 18:03:35 +04:00
|
|
|
{
|
2002-10-25 01:07:56 +04:00
|
|
|
bxevent_callback = func;
|
|
|
|
bxevent_callback_data = arg;
|
2001-06-11 18:03:35 +04:00
|
|
|
}
|
|
|
|
|
2007-10-14 04:20:30 +04:00
|
|
|
void bx_real_sim_c::get_notify_callback(bxevent_handler *func, void **arg)
|
2002-09-23 20:57:45 +04:00
|
|
|
{
|
2002-10-25 01:07:56 +04:00
|
|
|
*func = bxevent_callback;
|
|
|
|
*arg = bxevent_callback_data;
|
2002-09-23 20:57:45 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
BxEvent *bx_real_sim_c::sim_to_ci_event(BxEvent *event)
|
2001-06-11 18:03:35 +04:00
|
|
|
{
|
2002-10-25 01:07:56 +04:00
|
|
|
if (bxevent_callback == NULL) {
|
2006-03-07 20:54:27 +03:00
|
|
|
BX_ERROR(("notify called, but no bxevent_callback function is registered"));
|
2002-04-18 04:22:20 +04:00
|
|
|
return NULL;
|
2001-06-12 00:51:15 +04:00
|
|
|
} else {
|
2002-10-25 01:07:56 +04:00
|
|
|
return (*bxevent_callback)(bxevent_callback_data, event);
|
2001-06-11 18:03:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns 0 for continue, 1 for alwayscontinue, 2 for die.
|
2006-03-07 20:54:27 +03:00
|
|
|
int bx_real_sim_c::log_msg(const char *prefix, int level, const char *msg)
|
2001-06-11 18:03:35 +04:00
|
|
|
{
|
2002-09-26 02:54:23 +04:00
|
|
|
BxEvent be;
|
|
|
|
be.type = BX_SYNC_EVT_LOG_ASK;
|
|
|
|
be.u.logmsg.prefix = prefix;
|
|
|
|
be.u.logmsg.level = level;
|
|
|
|
be.u.logmsg.msg = msg;
|
2002-10-25 01:07:56 +04:00
|
|
|
// default return value in case something goes wrong.
|
2006-01-31 22:37:56 +03:00
|
|
|
be.retcode = BX_LOG_NOTIFY_FAILED;
|
|
|
|
// calling notify
|
2002-09-26 02:54:23 +04:00
|
|
|
sim_to_ci_event (&be);
|
|
|
|
return be.retcode;
|
2001-06-11 18:03:35 +04:00
|
|
|
}
|
|
|
|
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
// Called by simulator whenever it needs the user to choose a new value
|
2008-02-06 01:57:43 +03:00
|
|
|
// for a registered parameter. Create a synchronous ASK_PARAM event,
|
2002-08-29 18:59:37 +04:00
|
|
|
// send it to the CI, and wait for the response. The CI will call the
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
// set() method on the parameter if the user changes the value.
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::ask_param(bx_param_c *param)
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
{
|
2006-02-27 12:37:58 +03:00
|
|
|
BX_ASSERT(param != NULL);
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
// create appropriate event
|
2002-09-26 02:54:23 +04:00
|
|
|
BxEvent event;
|
|
|
|
event.type = BX_SYNC_EVT_ASK_PARAM;
|
2006-02-27 12:37:58 +03:00
|
|
|
event.u.param.param = param;
|
|
|
|
sim_to_ci_event(&event);
|
2002-09-26 02:54:23 +04:00
|
|
|
return event.retcode;
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
}
|
2001-06-16 03:52:34 +04:00
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::ask_param(const char *pname)
|
2006-02-22 22:18:29 +03:00
|
|
|
{
|
|
|
|
bx_param_c *paramptr = SIM->get_param(pname);
|
|
|
|
BX_ASSERT(paramptr != NULL);
|
|
|
|
// create appropriate event
|
|
|
|
BxEvent event;
|
|
|
|
event.type = BX_SYNC_EVT_ASK_PARAM;
|
|
|
|
event.u.param.param = paramptr;
|
|
|
|
sim_to_ci_event(&event);
|
|
|
|
return event.retcode;
|
|
|
|
}
|
|
|
|
|
2007-10-25 03:09:59 +04:00
|
|
|
int bx_real_sim_c::ask_filename(const char *filename, int maxlen, const char *prompt, const char *the_default, int flags)
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
{
|
|
|
|
BxEvent event;
|
2006-03-06 21:50:55 +03:00
|
|
|
bx_param_string_c param(NULL, "filename", prompt, "", the_default, maxlen);
|
- fixed up ParamDialog to correctly handle "trees" of parameters. A
bx_list_c can now be displayed as either a wxStaticBox with the
child parameters inside, or as a wxNotebook with each child
parameter in a separate tab. (The children can also be lists of
course.) The default display is the wxStaticBox type, but if you
set the option bit bx_list_c::USE_TAB_WINDOW in the list,
ParamDialog will use the wxNotebook display instead.
- to get the param trees working, I created a new struct
AddParamContext, which is passed to AddParam(). This struct is
critical when AddParam calls itself recursively to display lists
within lists.
- use the wxNotebook display feature for the ATA0,1,2,3 controller
dialog box. Now instead of being hundreds of pixels tall, it is
reasonable height with three different tabs. This fixed bug
#619074: "wx: ATA interface editor too tall" and was the whole
reason I started messing with this at all.
plus some minor cleanups
- when I added the enum constant bx_list_c::USE_TAB_WINDOW, I also
removed the BX_ prefix from all the other enum constants that are
used in parameter options in siminterface.cc. Since these constants
are enums within a class, there is no possibility of namespace
conflicts so the prefix is not needed.
- added wxADJUST_MINSIZE to all wxChoice controls, since that tells
wxWindows to adjust its size to the length of the longest string.
- instead of calling SetSize or SetSizeHints on every textcontrol with
a hardcoded width, I am using just two wxSize specifications for
everything: either normalTextSize or longTextSize.
- edit names of a few menus and params. For example now instead of
the tab saying "Master ATA device on channel 0" it will say
"First HD/CD on channel 0".
Modified Files:
main.cc gui/control.cc gui/gui.cc gui/siminterface.cc gui/siminterface.h
gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc
2002-10-06 06:37:28 +04:00
|
|
|
flags |= param.IS_FILENAME;
|
2009-03-16 00:16:17 +03:00
|
|
|
param.set_options(flags);
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
event.type = BX_SYNC_EVT_ASK_PARAM;
|
|
|
|
event.u.param.param = ¶m;
|
2006-06-01 00:12:43 +04:00
|
|
|
sim_to_ci_event(&event);
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
if (event.retcode >= 0)
|
2007-10-25 03:09:59 +04:00
|
|
|
memcpy((char *)filename, param.getptr(), maxlen);
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
return event.retcode;
|
|
|
|
}
|
|
|
|
|
2007-10-25 03:09:59 +04:00
|
|
|
int bx_real_sim_c::ask_yes_no(const char *title, const char *prompt, bx_bool the_default)
|
2006-06-01 00:12:43 +04:00
|
|
|
{
|
|
|
|
BxEvent event;
|
2006-06-04 11:55:34 +04:00
|
|
|
char format[512];
|
|
|
|
|
2006-06-01 00:12:43 +04:00
|
|
|
bx_param_bool_c param(NULL, "yes_no", title, prompt, the_default);
|
2006-06-04 11:55:34 +04:00
|
|
|
sprintf(format, "%s\n\n%s [%%s] ", title, prompt);
|
|
|
|
param.set_ask_format(format);
|
2006-06-01 00:12:43 +04:00
|
|
|
event.type = BX_SYNC_EVT_ASK_PARAM;
|
|
|
|
event.u.param.param = ¶m;
|
|
|
|
sim_to_ci_event(&event);
|
|
|
|
if (event.retcode >= 0) {
|
|
|
|
return param.get();
|
2008-09-20 01:31:08 +04:00
|
|
|
}
|
|
|
|
else {
|
2006-06-01 00:12:43 +04:00
|
|
|
return event.retcode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
void bx_real_sim_c::periodic()
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
{
|
2008-02-06 01:57:43 +03:00
|
|
|
// give the GUI a chance to do periodic things on the bochs thread. in
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
// particular, notice if the thread has been asked to die.
|
2002-09-26 02:54:23 +04:00
|
|
|
BxEvent tick;
|
|
|
|
tick.type = BX_SYNC_EVT_TICK;
|
|
|
|
sim_to_ci_event (&tick);
|
|
|
|
if (tick.retcode < 0) {
|
2006-03-07 20:54:27 +03:00
|
|
|
BX_INFO(("Bochs thread has been asked to quit."));
|
2006-09-04 22:36:47 +04:00
|
|
|
#if !BX_DEBUGGER
|
2006-03-07 20:54:27 +03:00
|
|
|
bx_atexit();
|
|
|
|
quit_sim(0);
|
2006-09-04 22:36:47 +04:00
|
|
|
#else
|
|
|
|
bx_dbg_exit(0);
|
|
|
|
#endif
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
}
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
static int refresh_counter = 0;
|
|
|
|
if (++refresh_counter == 50) {
|
|
|
|
// only ask the CI to refresh every 50 times periodic() is called.
|
|
|
|
// This should obviously be configurable because system speeds and
|
|
|
|
// user preferences vary.
|
2006-03-07 20:54:27 +03:00
|
|
|
refresh_ci();
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
refresh_counter = 0;
|
|
|
|
}
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
}
|
|
|
|
|
2002-08-30 00:13:05 +04:00
|
|
|
// create a disk image file called filename, size=512 bytes * sectors.
|
2006-04-07 00:42:51 +04:00
|
|
|
// If overwrite is 0 and the file exists, returns -1 without changing it.
|
2002-08-30 00:13:05 +04:00
|
|
|
// Otherwise, opens up the image and starts writing. Returns -2 if
|
|
|
|
// the image could not be opened, or -3 if there are failures during
|
|
|
|
// write, e.g. disk full.
|
2008-02-06 01:57:43 +03:00
|
|
|
//
|
2005-01-05 22:54:32 +03:00
|
|
|
// wxWidgets: This may be called from the gui thread.
|
2007-10-14 04:20:30 +04:00
|
|
|
int bx_real_sim_c::create_disk_image(const char *filename, int sectors, bx_bool overwrite)
|
2002-08-30 00:13:05 +04:00
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
if (!overwrite) {
|
|
|
|
// check for existence first
|
2006-03-07 20:54:27 +03:00
|
|
|
fp = fopen(filename, "r");
|
2002-08-30 00:13:05 +04:00
|
|
|
if (fp) {
|
|
|
|
// yes it exists
|
2006-03-07 20:54:27 +03:00
|
|
|
fclose(fp);
|
2002-08-30 00:13:05 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2006-03-07 20:54:27 +03:00
|
|
|
fp = fopen(filename, "w");
|
2002-08-30 00:13:05 +04:00
|
|
|
if (fp == NULL) {
|
|
|
|
#ifdef HAVE_PERROR
|
|
|
|
char buffer[1024];
|
2006-03-07 20:54:27 +03:00
|
|
|
sprintf(buffer, "while opening '%s' for writing", filename);
|
|
|
|
perror(buffer);
|
2002-08-30 00:13:05 +04:00
|
|
|
// not sure how to get this back into the CI
|
|
|
|
#endif
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
int sec = sectors;
|
|
|
|
/*
|
|
|
|
* seek to sec*512-1 and write a single character.
|
|
|
|
* can't just do: fseek(fp, 512*sec-1, SEEK_SET)
|
|
|
|
* because 512*sec may be too large for signed int.
|
|
|
|
*/
|
|
|
|
while (sec > 0)
|
|
|
|
{
|
|
|
|
/* temp <-- min(sec, 4194303)
|
|
|
|
* 4194303 is (int)(0x7FFFFFFF/512)
|
|
|
|
*/
|
|
|
|
int temp = ((sec < 4194303) ? sec : 4194303);
|
|
|
|
fseek(fp, 512*temp, SEEK_CUR);
|
|
|
|
sec -= temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
fseek(fp, -1, SEEK_CUR);
|
|
|
|
if (fputc('\0', fp) == EOF)
|
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
fclose(fp);
|
2002-08-30 00:13:05 +04:00
|
|
|
return -3;
|
|
|
|
}
|
2006-03-07 20:54:27 +03:00
|
|
|
fclose(fp);
|
2002-08-30 00:13:05 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-10-14 04:20:30 +04:00
|
|
|
void bx_real_sim_c::refresh_ci()
|
|
|
|
{
|
2006-11-12 13:07:18 +03:00
|
|
|
if (SIM->has_debug_gui()) {
|
2005-01-05 22:54:32 +03:00
|
|
|
// presently, only wxWidgets interface uses these events
|
2002-11-19 12:27:39 +03:00
|
|
|
// It's an async event, so allocate a pointer and send it.
|
|
|
|
// The event will be freed by the recipient.
|
2006-11-12 13:07:18 +03:00
|
|
|
BxEvent *event = new BxEvent();
|
2002-11-19 12:27:39 +03:00
|
|
|
event->type = BX_ASYNC_EVT_REFRESH;
|
2006-03-07 20:54:27 +03:00
|
|
|
sim_to_ci_event(event);
|
2002-11-19 12:27:39 +03:00
|
|
|
}
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
}
|
|
|
|
|
2007-10-14 04:20:30 +04:00
|
|
|
bx_param_c *bx_real_sim_c::get_first_atadevice(Bit32u search_type)
|
|
|
|
{
|
2006-02-26 22:11:20 +03:00
|
|
|
char pname[80];
|
2002-09-23 00:56:12 +04:00
|
|
|
for (int channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
|
2006-02-26 22:11:20 +03:00
|
|
|
sprintf(pname, "ata.%d.resources.enabled", channel);
|
|
|
|
if (!SIM->get_param_bool(pname)->get())
|
2002-09-23 00:56:12 +04:00
|
|
|
continue;
|
|
|
|
for (int slave=0; slave<2; slave++) {
|
2006-02-26 22:11:20 +03:00
|
|
|
sprintf(pname, "ata.%d.%s.present", channel, (slave==0)?"master":"slave");
|
|
|
|
Bit32u present = SIM->get_param_bool(pname)->get();
|
|
|
|
sprintf(pname, "ata.%d.%s.type", channel, (slave==0)?"master":"slave");
|
|
|
|
Bit32u type = SIM->get_param_enum(pname)->get();
|
2002-12-07 22:43:53 +03:00
|
|
|
if (present && (type == search_type)) {
|
2006-02-26 22:11:20 +03:00
|
|
|
sprintf(pname, "ata.%d.%s", channel, (slave==0)?"master":"slave");
|
|
|
|
return SIM->get_param(pname);
|
2002-09-23 00:56:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
#if BX_DEBUGGER
|
|
|
|
|
|
|
|
// this can be safely called from either thread.
|
2006-05-23 01:29:54 +04:00
|
|
|
void bx_real_sim_c::debug_break()
|
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
bx_debug_break();
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// this should only be called from the sim_thread.
|
2006-05-23 01:29:54 +04:00
|
|
|
void bx_real_sim_c::debug_interpret_cmd(char *cmd)
|
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
if (!is_sim_thread()) {
|
|
|
|
fprintf(stderr, "ERROR: debug_interpret_cmd called but not from sim_thread\n");
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
return;
|
|
|
|
}
|
2006-03-07 20:54:27 +03:00
|
|
|
bx_dbg_interpret_line(cmd);
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
char *bx_real_sim_c::debug_get_next_command()
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
{
|
|
|
|
BxEvent event;
|
|
|
|
event.type = BX_SYNC_EVT_GET_DBG_COMMAND;
|
2006-12-10 16:03:25 +03:00
|
|
|
BX_DEBUG(("asking for next debug command"));
|
2002-09-26 02:54:23 +04:00
|
|
|
sim_to_ci_event (&event);
|
2006-12-10 16:03:25 +03:00
|
|
|
BX_DEBUG(("received next debug command: '%s'", event.u.debugcmd.command));
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
if (event.retcode >= 0)
|
|
|
|
return event.u.debugcmd.command;
|
|
|
|
return NULL;
|
|
|
|
}
|
- add Debug Log dialog, which shows all the text output that is normally
printed to stderr in the text debugger. Also allows the user to
type (text) debugger commands directly, which also appear in the log.
- all text output in the debugger now passes through dbg_printf()
(used to be fprintf to stderr) so that in wxWindows I can redirect
it all to the wxWindows debug log screen. Added debug_fputs to
siminterface which actually sends the text to the GUI by creating
a BX_ASYNC_EVT_DBG_MSG event.
- changed prefix and msg fields of BxLogMsgEvent to const char *,
and also in args of logmsg method of siminterface.
- don't trap SIGINT in wxWindows. There are other ways to stop execution.
Also, signal handling with multiple threads is very strange and different
on different platforms.
- minor changes to fix gcc -Wall warnings in dbg_main.cc
- add a new boolean parameter BXP_DEBUG_RUNNING that tells if the debugger is
running freely or not. This is used by the wxWindows GUI to enable or
disable certain choices.
- CpuRegistersDialog has continue,stop,step buttons. When the sim is running
freely, I disable continue and step, and enable stop. When the sim stops
to wait for the user, I disable stop and enable continue and step. The
change of enables used to be triggered by actually pressing the button,
but then if you started/stopped the simulation in some other way (typing
in debug log window) the enables were never changed. Now the enables are
controlled by the value of BXP_DEBUG_RUNNING, which is set by the debug code
itself, and the buttons are enabled at the right time.
- ParamDialog::Refresh() is now virtual so that child classes can redefine
its refresh behavior.
- in safeWxStrcpy, force the last element of the array to be a 0, since
I noticed that strncpy is not guaranteed to terminate the string!
- modified: debug/dbg_main.cc debug/debug.h gui/siminterface.cc
gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc
gui/wxmain.h
2002-09-15 15:21:35 +04:00
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
void bx_real_sim_c::debug_puts(const char *text)
|
- add Debug Log dialog, which shows all the text output that is normally
printed to stderr in the text debugger. Also allows the user to
type (text) debugger commands directly, which also appear in the log.
- all text output in the debugger now passes through dbg_printf()
(used to be fprintf to stderr) so that in wxWindows I can redirect
it all to the wxWindows debug log screen. Added debug_fputs to
siminterface which actually sends the text to the GUI by creating
a BX_ASYNC_EVT_DBG_MSG event.
- changed prefix and msg fields of BxLogMsgEvent to const char *,
and also in args of logmsg method of siminterface.
- don't trap SIGINT in wxWindows. There are other ways to stop execution.
Also, signal handling with multiple threads is very strange and different
on different platforms.
- minor changes to fix gcc -Wall warnings in dbg_main.cc
- add a new boolean parameter BXP_DEBUG_RUNNING that tells if the debugger is
running freely or not. This is used by the wxWindows GUI to enable or
disable certain choices.
- CpuRegistersDialog has continue,stop,step buttons. When the sim is running
freely, I disable continue and step, and enable stop. When the sim stops
to wait for the user, I disable stop and enable continue and step. The
change of enables used to be triggered by actually pressing the button,
but then if you started/stopped the simulation in some other way (typing
in debug log window) the enables were never changed. Now the enables are
controlled by the value of BXP_DEBUG_RUNNING, which is set by the debug code
itself, and the buttons are enabled at the right time.
- ParamDialog::Refresh() is now virtual so that child classes can redefine
its refresh behavior.
- in safeWxStrcpy, force the last element of the array to be a 0, since
I noticed that strncpy is not guaranteed to terminate the string!
- modified: debug/dbg_main.cc debug/debug.h gui/siminterface.cc
gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc
gui/wxmain.h
2002-09-15 15:21:35 +04:00
|
|
|
{
|
2006-11-12 13:07:18 +03:00
|
|
|
if (SIM->has_debug_gui()) {
|
2005-01-05 22:54:32 +03:00
|
|
|
// send message to the wxWidgets debugger
|
2006-03-07 20:54:27 +03:00
|
|
|
BxEvent *event = new BxEvent();
|
2002-11-19 12:27:39 +03:00
|
|
|
event->type = BX_ASYNC_EVT_DBG_MSG;
|
|
|
|
event->u.logmsg.msg = text;
|
2006-11-12 13:07:18 +03:00
|
|
|
sim_to_ci_event(event);
|
2002-11-19 12:27:39 +03:00
|
|
|
} else {
|
|
|
|
// text mode debugger: just write to console
|
2009-02-12 23:39:38 +03:00
|
|
|
fputs(text, stdout);
|
2002-11-19 12:27:39 +03:00
|
|
|
}
|
- add Debug Log dialog, which shows all the text output that is normally
printed to stderr in the text debugger. Also allows the user to
type (text) debugger commands directly, which also appear in the log.
- all text output in the debugger now passes through dbg_printf()
(used to be fprintf to stderr) so that in wxWindows I can redirect
it all to the wxWindows debug log screen. Added debug_fputs to
siminterface which actually sends the text to the GUI by creating
a BX_ASYNC_EVT_DBG_MSG event.
- changed prefix and msg fields of BxLogMsgEvent to const char *,
and also in args of logmsg method of siminterface.
- don't trap SIGINT in wxWindows. There are other ways to stop execution.
Also, signal handling with multiple threads is very strange and different
on different platforms.
- minor changes to fix gcc -Wall warnings in dbg_main.cc
- add a new boolean parameter BXP_DEBUG_RUNNING that tells if the debugger is
running freely or not. This is used by the wxWindows GUI to enable or
disable certain choices.
- CpuRegistersDialog has continue,stop,step buttons. When the sim is running
freely, I disable continue and step, and enable stop. When the sim stops
to wait for the user, I disable stop and enable continue and step. The
change of enables used to be triggered by actually pressing the button,
but then if you started/stopped the simulation in some other way (typing
in debug log window) the enables were never changed. Now the enables are
controlled by the value of BXP_DEBUG_RUNNING, which is set by the debug code
itself, and the buttons are enabled at the right time.
- ParamDialog::Refresh() is now virtual so that child classes can redefine
its refresh behavior.
- in safeWxStrcpy, force the last element of the array to be a 0, since
I noticed that strncpy is not guaranteed to terminate the string!
- modified: debug/dbg_main.cc debug/debug.h gui/siminterface.cc
gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc
gui/wxmain.h
2002-09-15 15:21:35 +04:00
|
|
|
}
|
- add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger. The Bochs debugger calls SIM->debug_get_next_command() which
does not return until a debugger command is found. The siminterface sends an
synchronous event to the wxWindows thread with a blank to be filled in with a
debugger command. wxWindows fills in the blank and sends the synchronous
event back, and the Bochs debugger interprets it as if it was typed on
the command line. For the long term I haven't decided whether to stick with
sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
some things to protected members&fields, separating out functionality
that is most likely to be replaced into virtual functions, and making it
generally more flexible. The new CpuRegistersDialog is based on
ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
where they don't exist. Add an eflags shadow parameter that represents all
of the bits of eflags at once. There are also boolean shadow params for
each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h
2002-09-13 23:39:38 +04:00
|
|
|
#endif
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
void bx_real_sim_c::register_configuration_interface(
|
2008-02-06 01:57:43 +03:00
|
|
|
const char* name,
|
2002-10-25 01:07:56 +04:00
|
|
|
config_interface_callback_t callback,
|
|
|
|
void *userdata)
|
|
|
|
{
|
|
|
|
ci_callback = callback;
|
|
|
|
ci_callback_data = userdata;
|
|
|
|
registered_ci_name = name;
|
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_real_sim_c::configuration_interface(const char *ignore, ci_command_t command)
|
2002-10-25 01:07:56 +04:00
|
|
|
{
|
2006-02-22 00:35:09 +03:00
|
|
|
bx_param_enum_c *ci_param = SIM->get_param_enum(BXPN_SEL_CONFIG_INTERFACE);
|
2007-10-25 03:09:59 +04:00
|
|
|
const char *name = ci_param->get_selected();
|
2002-10-25 01:07:56 +04:00
|
|
|
if (!ci_callback) {
|
2006-02-22 00:35:09 +03:00
|
|
|
BX_PANIC(("no configuration interface was loaded"));
|
2002-10-25 01:07:56 +04:00
|
|
|
return -1;
|
|
|
|
}
|
2006-02-22 00:35:09 +03:00
|
|
|
if (strcmp(name, registered_ci_name) != 0) {
|
|
|
|
BX_PANIC(("siminterface does not support loading one configuration interface and then calling another"));
|
2002-10-25 01:07:56 +04:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-06 01:57:43 +03:00
|
|
|
if (!strcmp(name, "wx"))
|
2006-11-12 13:07:18 +03:00
|
|
|
debug_gui = 1;
|
2002-11-19 12:27:39 +03:00
|
|
|
else
|
2006-11-12 13:07:18 +03:00
|
|
|
debug_gui = 0;
|
2002-12-06 22:34:32 +03:00
|
|
|
// enter configuration mode, just while running the configuration interface
|
2006-02-22 00:35:09 +03:00
|
|
|
set_display_mode(DISP_MODE_CONFIG);
|
2002-12-06 22:34:32 +03:00
|
|
|
int retval = (*ci_callback)(ci_callback_data, command);
|
2006-02-22 00:35:09 +03:00
|
|
|
set_display_mode(DISP_MODE_SIM);
|
2002-12-06 22:34:32 +03:00
|
|
|
return retval;
|
2002-10-25 01:07:56 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
int bx_real_sim_c::begin_simulation(int argc, char *argv[])
|
2002-10-25 01:07:56 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
return bx_begin_simulation(argc, argv);
|
2002-10-25 01:07:56 +04:00
|
|
|
}
|
|
|
|
|
2006-04-07 00:42:51 +04:00
|
|
|
bx_bool bx_real_sim_c::is_sim_thread()
|
2002-10-25 01:07:56 +04:00
|
|
|
{
|
2006-04-07 00:42:51 +04:00
|
|
|
if (is_sim_thread_func == NULL) return 1;
|
2002-10-25 01:07:56 +04:00
|
|
|
return (*is_sim_thread_func)();
|
|
|
|
}
|
|
|
|
|
2002-12-17 08:58:45 +03:00
|
|
|
// check if the text console exists. On some platforms, if Bochs is
|
|
|
|
// started from the "Start Menu" or by double clicking on it on a Mac,
|
|
|
|
// there may be nothing attached to stdin/stdout/stderr. This function
|
2006-04-07 00:42:51 +04:00
|
|
|
// tests if stdin/stdout/stderr are usable and returns 0 if not.
|
|
|
|
bx_bool bx_real_sim_c::test_for_text_console()
|
2002-12-17 08:58:45 +03:00
|
|
|
{
|
|
|
|
#if BX_WITH_CARBON
|
|
|
|
// In a Carbon application, you have a text console if you run the app from
|
|
|
|
// the command line, but if you start it from the finder you don't.
|
2006-04-07 00:42:51 +04:00
|
|
|
if(!isatty(STDIN_FILENO)) return 0;
|
2002-12-17 08:58:45 +03:00
|
|
|
#endif
|
|
|
|
// default: yes
|
2006-04-07 00:42:51 +04:00
|
|
|
return 1;
|
2002-12-17 08:58:45 +03:00
|
|
|
}
|
|
|
|
|
2009-01-06 23:35:39 +03:00
|
|
|
bx_bool bx_real_sim_c::is_user_option(const char *keyword)
|
2006-03-29 23:27:31 +04:00
|
|
|
{
|
2009-01-06 23:35:39 +03:00
|
|
|
user_option_t *user_option;
|
|
|
|
|
|
|
|
for (user_option = user_options; user_option; user_option = user_option->next) {
|
|
|
|
if (!strcmp(user_option->name, keyword)) return 1;
|
2006-04-05 20:05:11 +04:00
|
|
|
}
|
2009-01-06 23:35:39 +03:00
|
|
|
return 0;
|
2006-03-29 23:27:31 +04:00
|
|
|
}
|
|
|
|
|
2006-04-14 12:07:24 +04:00
|
|
|
bx_bool bx_real_sim_c::register_user_option(const char *keyword, user_option_parser_t parser,
|
|
|
|
user_option_save_t save_func)
|
2006-03-29 23:27:31 +04:00
|
|
|
{
|
2009-01-06 23:35:39 +03:00
|
|
|
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"));
|
2006-04-05 20:05:11 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2009-01-06 23:35:39 +03:00
|
|
|
|
|
|
|
user_option->name = keyword;
|
|
|
|
user_option->parser = parser;
|
|
|
|
user_option->savefn = save_func;
|
|
|
|
user_option->next = NULL;
|
|
|
|
|
|
|
|
if (user_options == NULL) {
|
|
|
|
user_options = user_option;
|
2006-04-05 20:05:11 +04:00
|
|
|
} else {
|
2009-01-06 23:35:39 +03:00
|
|
|
user_option_t *temp = user_options;
|
|
|
|
|
|
|
|
while (temp->next) {
|
|
|
|
if (!strcmp(temp->name, keyword)) {
|
|
|
|
free(user_option);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
temp = temp->next;
|
|
|
|
}
|
|
|
|
temp->next = user_option;
|
2006-04-05 20:05:11 +04:00
|
|
|
}
|
2009-01-06 23:35:39 +03:00
|
|
|
return 1;
|
2006-03-29 23:27:31 +04:00
|
|
|
}
|
|
|
|
|
2009-01-05 00:46:20 +03:00
|
|
|
bx_bool bx_real_sim_c::unregister_user_option(const char *keyword)
|
|
|
|
{
|
2009-01-06 23:35:39 +03:00
|
|
|
user_option_t *user_option, *prev = NULL;
|
|
|
|
|
|
|
|
for (user_option = user_options; user_option; user_option = user_option->next) {
|
|
|
|
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;
|
2009-01-05 00:46:20 +03:00
|
|
|
}
|
|
|
|
}
|
2009-01-06 23:35:39 +03:00
|
|
|
return 0;
|
2009-01-05 00:46:20 +03:00
|
|
|
}
|
|
|
|
|
2009-01-06 23:35:39 +03:00
|
|
|
Bit32s bx_real_sim_c::parse_user_option(const char *context, int num_params, char *params [])
|
2006-03-29 23:27:31 +04:00
|
|
|
{
|
2009-01-06 23:35:39 +03:00
|
|
|
user_option_t *user_option;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2006-04-05 20:05:11 +04:00
|
|
|
}
|
2009-01-06 23:35:39 +03:00
|
|
|
return -1;
|
|
|
|
|
2006-04-14 12:07:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Bit32s bx_real_sim_c::save_user_options(FILE *fp)
|
|
|
|
{
|
2009-01-06 23:35:39 +03:00
|
|
|
user_option_t *user_option;
|
|
|
|
|
|
|
|
for (user_option = user_options; user_option; user_option = user_option->next) {
|
|
|
|
if (user_option->savefn != NULL) {
|
|
|
|
(*user_option->savefn)(fp);
|
2006-04-14 12:07:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2006-03-29 23:27:31 +04:00
|
|
|
}
|
|
|
|
|
2006-09-07 22:50:51 +04:00
|
|
|
void bx_real_sim_c::init_save_restore()
|
|
|
|
{
|
|
|
|
bx_list_c *list;
|
|
|
|
|
2007-09-28 23:52:08 +04:00
|
|
|
if ((list = get_bochs_root()) != NULL) {
|
2006-09-07 22:50:51 +04:00
|
|
|
list->clear();
|
|
|
|
} else {
|
|
|
|
list = new bx_list_c(root_param,
|
2007-09-28 23:52:08 +04:00
|
|
|
"bochs",
|
2008-02-06 01:57:43 +03:00
|
|
|
"subtree for save/restore",
|
2007-10-14 23:04:51 +04:00
|
|
|
30 + BX_MAX_SMP_THREADS_SUPPORTED);
|
2006-09-07 22:50:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-07 16:49:50 +04:00
|
|
|
bx_bool bx_real_sim_c::save_state(const char *checkpoint_path)
|
2006-04-07 00:42:51 +04:00
|
|
|
{
|
2006-04-15 18:05:18 +04:00
|
|
|
char sr_file[BX_PATHNAME_LEN];
|
2006-04-09 13:05:30 +04:00
|
|
|
char prefix[8];
|
|
|
|
int i, dev, ndev = SIM->get_n_log_modules();
|
|
|
|
int type, ntype = SIM->get_max_log_level();
|
2006-04-07 16:49:50 +04:00
|
|
|
|
2006-04-15 18:05:18 +04:00
|
|
|
sprintf(sr_file, "%s/config", checkpoint_path);
|
2006-05-28 20:39:25 +04:00
|
|
|
if (write_rc(sr_file, 1) < 0)
|
|
|
|
return 0;
|
2006-04-15 18:05:18 +04:00
|
|
|
sprintf(sr_file, "%s/logopts", checkpoint_path);
|
2007-10-14 04:20:30 +04:00
|
|
|
FILE *fp = fopen(sr_file, "w");
|
2006-04-09 13:05:30 +04:00
|
|
|
if (fp != NULL) {
|
|
|
|
for (dev=0; dev<ndev; dev++) {
|
|
|
|
strcpy(prefix, get_prefix(dev));
|
|
|
|
strcpy(prefix, prefix+1);
|
|
|
|
prefix[strlen(prefix) - 1] = 0;
|
|
|
|
i = strlen(prefix) - 1;
|
|
|
|
while ((i >= 0) && (prefix[i] == ' ')) prefix[i--] = 0;
|
|
|
|
if (strlen(prefix) > 0) {
|
|
|
|
fprintf(fp, "%s: ", prefix);
|
|
|
|
for (type=0; type<ntype; type++) {
|
|
|
|
if (type > 0) fprintf(fp, ", ");
|
|
|
|
fprintf(fp, "%s=%s", get_log_level_name(type), get_action_name(get_log_action(dev, type)));
|
|
|
|
}
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
2006-05-28 20:39:25 +04:00
|
|
|
} else {
|
|
|
|
return 0;
|
2006-04-09 13:05:30 +04:00
|
|
|
}
|
2007-09-28 23:52:08 +04:00
|
|
|
bx_list_c *sr_list = get_bochs_root();
|
2006-04-15 18:05:18 +04:00
|
|
|
ndev = sr_list->get_size();
|
|
|
|
for (dev=0; dev<ndev; dev++) {
|
|
|
|
sprintf(sr_file, "%s/%s", checkpoint_path, sr_list->get(dev)->get_name());
|
|
|
|
fp = fopen(sr_file, "w");
|
|
|
|
if (fp != NULL) {
|
2006-05-01 22:24:47 +04:00
|
|
|
save_sr_param(fp, sr_list->get(dev), checkpoint_path, 0);
|
2006-04-15 18:05:18 +04:00
|
|
|
fclose(fp);
|
2006-05-28 20:39:25 +04:00
|
|
|
} else {
|
|
|
|
return 0;
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
|
|
|
}
|
2006-05-28 20:39:25 +04:00
|
|
|
return 1;
|
2006-04-07 00:42:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bx_bool bx_real_sim_c::restore_config()
|
|
|
|
{
|
2006-04-07 16:49:50 +04:00
|
|
|
char config[BX_PATHNAME_LEN];
|
|
|
|
sprintf(config, "%s/config", get_param_string(BXPN_RESTORE_PATH)->getptr());
|
|
|
|
BX_INFO(("restoring '%s'", config));
|
2006-05-28 20:39:25 +04:00
|
|
|
return (read_rc(config) >= 0);
|
2006-04-07 00:42:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bx_bool bx_real_sim_c::restore_logopts()
|
|
|
|
{
|
2006-04-09 13:05:30 +04:00
|
|
|
char logopts[BX_PATHNAME_LEN];
|
|
|
|
char line[512], string[512], prefix[8];
|
|
|
|
char *ret, *ptr;
|
|
|
|
int d, i, j, dev = 0, type = 0, action = 0;
|
|
|
|
int ndev = SIM->get_n_log_modules();
|
2006-04-15 18:05:18 +04:00
|
|
|
FILE *fp;
|
2006-04-09 13:05:30 +04:00
|
|
|
|
|
|
|
sprintf(logopts, "%s/logopts", get_param_string(BXPN_RESTORE_PATH)->getptr());
|
|
|
|
BX_INFO(("restoring '%s'", logopts));
|
|
|
|
fp = fopen(logopts, "r");
|
|
|
|
if (fp != NULL) {
|
|
|
|
do {
|
|
|
|
ret = fgets(line, sizeof(line)-1, fp);
|
|
|
|
line[sizeof(line) - 1] = '\0';
|
|
|
|
int len = strlen(line);
|
|
|
|
if ((len>0) && (line[len-1] < ' '))
|
|
|
|
line[len-1] = '\0';
|
|
|
|
i = 0;
|
|
|
|
if ((ret != NULL) && strlen(line)) {
|
|
|
|
ptr = strtok(line, ":");
|
|
|
|
while (ptr) {
|
|
|
|
strcpy(string, ptr);
|
|
|
|
while (isspace(string[0])) strcpy(string, string+1);
|
|
|
|
while (isspace(string[strlen(string)-1])) string[strlen(string)-1] = 0;
|
|
|
|
if (i == 0) {
|
|
|
|
sprintf(prefix, "[%-5s]", string);
|
|
|
|
dev = -1;
|
|
|
|
for (d = 0; d < ndev; d++) {
|
|
|
|
if (!strcmp(prefix, get_prefix(d))) {
|
|
|
|
dev = d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (dev >= 0) {
|
|
|
|
j = 6;
|
|
|
|
if (!strncmp(string, "DEBUG=", 6)) {
|
|
|
|
type = LOGLEV_DEBUG;
|
|
|
|
} else if (!strncmp(string, "INFO=", 5)) {
|
|
|
|
type = LOGLEV_INFO;
|
|
|
|
j = 5;
|
|
|
|
} else if (!strncmp(string, "ERROR=", 6)) {
|
|
|
|
type = LOGLEV_ERROR;
|
|
|
|
} else if (!strncmp(string, "PANIC=", 6)) {
|
|
|
|
type = LOGLEV_PANIC;
|
|
|
|
} else if (!strncmp(string, "PASS=", 5)) {
|
|
|
|
type = LOGLEV_PASS;
|
|
|
|
j = 5;
|
|
|
|
}
|
|
|
|
if (!strcmp(string+j, "ignore")) {
|
|
|
|
action = ACT_IGNORE;
|
|
|
|
} else if (!strcmp(string+j, "report")) {
|
|
|
|
action = ACT_REPORT;
|
|
|
|
} else if (!strcmp(string+j, "ask")) {
|
|
|
|
action = ACT_ASK;
|
|
|
|
} else if (!strcmp(string+j, "fatal")) {
|
|
|
|
action = ACT_FATAL;
|
|
|
|
}
|
|
|
|
set_log_action(dev, type, action);
|
|
|
|
} else {
|
|
|
|
if (i == 1) {
|
|
|
|
BX_ERROR(("restore_logopts(): log module '%s' not found", prefix));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
ptr = strtok(NULL, ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!feof(fp));
|
|
|
|
fclose(fp);
|
2006-05-28 20:39:25 +04:00
|
|
|
} else {
|
|
|
|
return 0;
|
2006-04-09 13:05:30 +04:00
|
|
|
}
|
2006-05-28 20:39:25 +04:00
|
|
|
return 1;
|
2006-04-07 00:42:51 +04:00
|
|
|
}
|
|
|
|
|
2007-10-14 23:04:51 +04:00
|
|
|
bx_bool bx_real_sim_c::restore_bochs_param(bx_list_c *root, const char *sr_path, const char *restore_name)
|
2006-04-07 00:42:51 +04:00
|
|
|
{
|
2006-04-15 18:05:18 +04:00
|
|
|
char devstate[BX_PATHNAME_LEN], devdata[BX_PATHNAME_LEN];
|
2006-05-01 22:24:47 +04:00
|
|
|
char line[512], buf[512], pname[80];
|
2006-04-15 18:05:18 +04:00
|
|
|
char *ret, *ptr;
|
2007-10-14 04:20:30 +04:00
|
|
|
int i, j, p;
|
|
|
|
unsigned n;
|
2006-04-15 18:05:18 +04:00
|
|
|
bx_param_c *param = NULL;
|
|
|
|
FILE *fp, *fp2;
|
|
|
|
|
2007-10-14 23:04:51 +04:00
|
|
|
if (root->get_by_name(restore_name) == NULL) {
|
|
|
|
BX_ERROR(("restore_bochs_param(): unknown parameter to restore"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-10-14 04:20:30 +04:00
|
|
|
sprintf(devstate, "%s/%s", sr_path, restore_name);
|
|
|
|
BX_INFO(("restoring '%s'", devstate));
|
|
|
|
bx_list_c *base = root;
|
|
|
|
fp = fopen(devstate, "r");
|
|
|
|
if (fp != NULL) {
|
|
|
|
do {
|
|
|
|
ret = fgets(line, sizeof(line)-1, fp);
|
|
|
|
line[sizeof(line) - 1] = '\0';
|
|
|
|
int len = strlen(line);
|
|
|
|
if ((len>0) && (line[len-1] < ' '))
|
|
|
|
line[len-1] = '\0';
|
|
|
|
i = 0;
|
|
|
|
if ((ret != NULL) && strlen(line)) {
|
|
|
|
ptr = strtok(line, " ");
|
|
|
|
while (ptr) {
|
|
|
|
if (i == 0) {
|
|
|
|
if (!strcmp(ptr, "}")) {
|
|
|
|
base = (bx_list_c*)base->get_parent();
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
param = get_param(ptr, base);
|
|
|
|
}
|
|
|
|
} else if (i == 2) {
|
2008-12-28 23:30:48 +03:00
|
|
|
if (param == NULL) {
|
|
|
|
BX_PANIC(("cannot find param!"));
|
2007-10-14 04:20:30 +04:00
|
|
|
}
|
2008-12-28 23:30:48 +03:00
|
|
|
else {
|
|
|
|
if (param->get_type() != BXT_LIST) {
|
|
|
|
param->get_param_path(pname, 80);
|
|
|
|
BX_DEBUG(("restoring parameter '%s'", pname));
|
|
|
|
}
|
|
|
|
switch (param->get_type()) {
|
|
|
|
case BXT_PARAM_NUM:
|
|
|
|
if ((ptr[0] == '0') && (ptr[1] == 'x')) {
|
|
|
|
((bx_param_num_c*)param)->set(strtoull(ptr, NULL, 16));
|
|
|
|
} else {
|
|
|
|
((bx_param_num_c*)param)->set(strtoull(ptr, NULL, 10));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BXT_PARAM_BOOL:
|
|
|
|
((bx_param_bool_c*)param)->set(!strcmp(ptr, "true"));
|
|
|
|
break;
|
|
|
|
case BXT_PARAM_ENUM:
|
|
|
|
((bx_param_enum_c*)param)->set_by_name(ptr);
|
|
|
|
break;
|
|
|
|
case BXT_PARAM_STRING:
|
2009-03-16 00:16:17 +03:00
|
|
|
if (((bx_param_string_c*)param)->get_options() & bx_param_string_c::RAW_BYTES) {
|
2008-12-28 23:30:48 +03:00
|
|
|
p = 0;
|
|
|
|
for (j = 0; j < ((bx_param_string_c*)param)->get_maxsize(); j++) {
|
|
|
|
if (ptr[p] == ((bx_param_string_c*)param)->get_separator()) {
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
if (sscanf(ptr+p, "%02x", &n) == 1) {
|
|
|
|
buf[j] = n;
|
|
|
|
p += 2;
|
|
|
|
}
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
2008-12-28 23:30:48 +03:00
|
|
|
((bx_param_string_c*)param)->set(buf);
|
|
|
|
} else {
|
|
|
|
((bx_param_string_c*)param)->set(ptr);
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
2008-12-28 23:30:48 +03:00
|
|
|
break;
|
|
|
|
case BXT_PARAM_DATA:
|
|
|
|
sprintf(devdata, "%s/%s", sr_path, ptr);
|
|
|
|
fp2 = fopen(devdata, "rb");
|
|
|
|
if (fp2 != NULL) {
|
|
|
|
fread(((bx_shadow_data_c*)param)->getptr(), 1, ((bx_shadow_data_c*)param)->get_size(), fp2);
|
|
|
|
fclose(fp2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BXT_LIST:
|
|
|
|
base = (bx_list_c*)param;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BX_ERROR(("restore_sr_param(): unknown parameter type"));
|
|
|
|
}
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
|
|
|
}
|
2007-10-14 04:20:30 +04:00
|
|
|
i++;
|
|
|
|
ptr = strtok(NULL, " ");
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
2007-10-14 04:20:30 +04:00
|
|
|
}
|
|
|
|
} while (!feof(fp));
|
|
|
|
fclose(fp);
|
|
|
|
} else {
|
2007-10-14 23:04:51 +04:00
|
|
|
BX_ERROR(("restore_bochs_param(): error in file open"));
|
2007-10-14 04:20:30 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bx_bool bx_real_sim_c::restore_hardware()
|
|
|
|
{
|
|
|
|
bx_list_c *sr_list = get_bochs_root();
|
|
|
|
int ndev = sr_list->get_size();
|
|
|
|
for (int dev=0; dev<ndev; dev++) {
|
2007-10-14 23:04:51 +04:00
|
|
|
if (!restore_bochs_param(sr_list, get_param_string(BXPN_RESTORE_PATH)->getptr(), sr_list->get(dev)->get_name()))
|
2006-05-28 20:39:25 +04:00
|
|
|
return 0;
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
2006-05-28 20:39:25 +04:00
|
|
|
return 1;
|
2006-04-07 00:42:51 +04:00
|
|
|
}
|
2006-04-15 18:05:18 +04:00
|
|
|
|
2007-10-14 04:20:30 +04:00
|
|
|
bx_bool bx_real_sim_c::save_sr_param(FILE *fp, bx_param_c *node, const char *sr_path, int level)
|
2006-04-15 18:05:18 +04:00
|
|
|
{
|
|
|
|
int i;
|
2006-05-29 23:57:12 +04:00
|
|
|
Bit64s value;
|
2006-04-15 18:05:18 +04:00
|
|
|
char tmpstr[BX_PATHNAME_LEN], tmpbyte[4];
|
|
|
|
FILE *fp2;
|
|
|
|
|
2006-05-01 22:24:47 +04:00
|
|
|
for (i=0; i<level; i++)
|
|
|
|
fprintf(fp, " ");
|
2006-04-15 18:05:18 +04:00
|
|
|
if (node == NULL) {
|
|
|
|
BX_ERROR(("NULL pointer"));
|
2007-10-14 04:20:30 +04:00
|
|
|
return 0;
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
2006-05-01 22:24:47 +04:00
|
|
|
fprintf(fp, "%s = ", node->get_name());
|
2006-04-15 18:05:18 +04:00
|
|
|
switch (node->get_type()) {
|
|
|
|
case BXT_PARAM_NUM:
|
2006-05-29 23:57:12 +04:00
|
|
|
value = ((bx_param_num_c*)node)->get64();
|
2006-05-23 01:29:54 +04:00
|
|
|
if (((bx_param_num_c*)node)->get_base() == BASE_DEC) {
|
2006-04-22 22:14:55 +04:00
|
|
|
if (((bx_param_num_c*)node)->get_min() >= BX_MIN_BIT64U) {
|
2006-05-30 20:05:51 +04:00
|
|
|
if ((Bit64u)((bx_param_num_c*)node)->get_max() > BX_MAX_BIT32U) {
|
|
|
|
fprintf(fp, FMT_LL"u\n", value);
|
2006-04-22 22:14:55 +04:00
|
|
|
} else {
|
2006-05-29 23:57:12 +04:00
|
|
|
fprintf(fp, "%u\n", (Bit32u) value);
|
2006-04-22 22:14:55 +04:00
|
|
|
}
|
|
|
|
} else {
|
2006-05-29 23:57:12 +04:00
|
|
|
fprintf(fp, "%d\n", (Bit32s) value);
|
2006-04-22 22:14:55 +04:00
|
|
|
}
|
2006-04-15 18:05:18 +04:00
|
|
|
} else {
|
2006-05-27 18:02:34 +04:00
|
|
|
if (node->get_format()) {
|
2006-05-29 23:57:12 +04:00
|
|
|
fprintf(fp, node->get_format(), value);
|
2006-05-27 18:02:34 +04:00
|
|
|
} else {
|
2006-05-29 23:57:12 +04:00
|
|
|
if ((Bit64u)((bx_param_num_c*)node)->get_max() > BX_MAX_BIT32U) {
|
|
|
|
fprintf(fp, "0x"FMT_LL"x", (Bit64u) value);
|
|
|
|
} else {
|
|
|
|
fprintf(fp, "0x%x", (Bit32u) value);
|
|
|
|
}
|
2006-05-27 18:02:34 +04:00
|
|
|
}
|
2006-04-22 22:14:55 +04:00
|
|
|
fprintf(fp, "\n");
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BXT_PARAM_BOOL:
|
|
|
|
fprintf(fp, "%s\n", ((bx_param_bool_c*)node)->get()?"true":"false");
|
|
|
|
break;
|
|
|
|
case BXT_PARAM_ENUM:
|
|
|
|
fprintf(fp, "%s\n", ((bx_param_enum_c*)node)->get_selected());
|
|
|
|
break;
|
|
|
|
case BXT_PARAM_STRING:
|
2009-03-16 00:16:17 +03:00
|
|
|
if (((bx_param_string_c*)node)->get_options() & bx_param_string_c::RAW_BYTES) {
|
2006-04-15 18:05:18 +04:00
|
|
|
tmpstr[0] = 0;
|
|
|
|
for (i = 0; i < ((bx_param_string_c*)node)->get_maxsize(); i++) {
|
|
|
|
if (i > 0) {
|
|
|
|
tmpbyte[0] = ((bx_param_string_c*)node)->get_separator();
|
|
|
|
tmpbyte[1] = 0;
|
|
|
|
strcat(tmpstr, tmpbyte);
|
|
|
|
}
|
|
|
|
sprintf(tmpbyte, "%02x", (Bit8u)((bx_param_string_c*)node)->getptr()[i]);
|
|
|
|
strcat(tmpstr, tmpbyte);
|
|
|
|
}
|
|
|
|
fprintf(fp, "%s\n", tmpstr);
|
|
|
|
} else {
|
|
|
|
fprintf(fp, "%s\n", ((bx_param_string_c*)node)->getptr());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BXT_PARAM_DATA:
|
2006-04-22 22:14:55 +04:00
|
|
|
fprintf(fp, "%s.%s\n", node->get_parent()->get_name(), node->get_name());
|
2006-06-11 20:40:37 +04:00
|
|
|
if (sr_path)
|
2006-06-11 22:03:11 +04:00
|
|
|
sprintf(tmpstr, "%s/%s.%s", sr_path, node->get_parent()->get_name(), node->get_name());
|
2006-06-11 20:40:37 +04:00
|
|
|
else
|
2006-06-11 22:03:11 +04:00
|
|
|
sprintf(tmpstr, "%s.%s", node->get_parent()->get_name(), node->get_name());
|
2006-04-15 18:05:18 +04:00
|
|
|
fp2 = fopen(tmpstr, "wb");
|
2006-06-16 13:10:26 +04:00
|
|
|
if (fp2 != NULL) {
|
2006-04-15 18:05:18 +04:00
|
|
|
fwrite(((bx_shadow_data_c*)node)->getptr(), 1, ((bx_shadow_data_c*)node)->get_size(), fp2);
|
|
|
|
fclose(fp2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BXT_LIST:
|
|
|
|
{
|
2006-05-01 22:24:47 +04:00
|
|
|
fprintf(fp, "{\n");
|
2006-04-15 18:05:18 +04:00
|
|
|
bx_list_c *list = (bx_list_c*)node;
|
|
|
|
for (i=0; i < list->get_size(); i++) {
|
2006-05-01 22:24:47 +04:00
|
|
|
save_sr_param(fp, list->get(i), sr_path, level+1);
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
2006-05-01 22:24:47 +04:00
|
|
|
for (i=0; i<level; i++)
|
|
|
|
fprintf(fp, " ");
|
|
|
|
fprintf(fp, "}\n");
|
2006-04-15 18:05:18 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
BX_ERROR(("save_sr_param(): unknown parameter type"));
|
2007-10-14 04:20:30 +04:00
|
|
|
return 0;
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
2007-10-14 04:20:30 +04:00
|
|
|
|
|
|
|
return 1;
|
2006-04-15 18:05:18 +04:00
|
|
|
}
|
2002-12-17 08:58:45 +03:00
|
|
|
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// define methods of bx_param_* and family
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2001-06-16 03:52:34 +04:00
|
|
|
|
2006-05-30 21:01:27 +04:00
|
|
|
const char* bx_param_c::default_text_format = NULL;
|
2001-06-16 03:52:34 +04:00
|
|
|
|
2006-05-30 21:01:27 +04:00
|
|
|
bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_desc)
|
2008-02-06 01:57:43 +03:00
|
|
|
: bx_object_c(id),
|
2006-06-05 23:06:36 +04:00
|
|
|
parent(NULL),
|
2008-02-06 01:57:43 +03:00
|
|
|
description(NULL),
|
|
|
|
label(NULL),
|
2006-06-05 23:06:36 +04:00
|
|
|
ask_format(NULL),
|
|
|
|
group_name(NULL)
|
2001-06-16 03:52:34 +04:00
|
|
|
{
|
2006-05-30 21:01:27 +04:00
|
|
|
set_type(BXT_PARAM);
|
|
|
|
this->name = new char[strlen(param_name)+1];
|
|
|
|
strcpy(this->name, param_name);
|
|
|
|
set_description(param_desc);
|
|
|
|
this->text_format = default_text_format;
|
|
|
|
this->long_text_format = default_text_format;
|
|
|
|
this->runtime_param = 0;
|
|
|
|
this->enabled = 1;
|
2001-06-16 03:52:34 +04:00
|
|
|
}
|
|
|
|
|
2006-05-30 21:01:27 +04:00
|
|
|
bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_label, const char *param_desc)
|
2006-06-05 23:06:36 +04:00
|
|
|
: bx_object_c(id),
|
|
|
|
parent(NULL),
|
2008-02-06 01:57:43 +03:00
|
|
|
description(NULL),
|
|
|
|
label(NULL),
|
2006-06-05 23:06:36 +04:00
|
|
|
ask_format(NULL),
|
|
|
|
group_name(NULL)
|
2001-06-16 03:52:34 +04:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
set_type(BXT_PARAM);
|
2006-05-30 02:33:38 +04:00
|
|
|
this->name = new char[strlen(param_name)+1];
|
|
|
|
strcpy(this->name, param_name);
|
2006-05-30 21:01:27 +04:00
|
|
|
set_description(param_desc);
|
|
|
|
set_label(param_label);
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
this->text_format = default_text_format;
|
2006-02-19 18:43:03 +03:00
|
|
|
this->long_text_format = default_text_format;
|
2001-06-18 18:11:55 +04:00
|
|
|
this->runtime_param = 0;
|
2001-06-21 18:37:55 +04:00
|
|
|
this->enabled = 1;
|
2001-06-16 03:52:34 +04:00
|
|
|
}
|
|
|
|
|
2006-05-30 02:33:38 +04:00
|
|
|
bx_param_c::~bx_param_c()
|
|
|
|
{
|
|
|
|
delete [] name;
|
2006-05-30 21:01:27 +04:00
|
|
|
delete [] label;
|
|
|
|
delete [] description;
|
2006-06-05 20:47:55 +04:00
|
|
|
delete [] ask_format;
|
2006-06-05 23:06:36 +04:00
|
|
|
delete [] group_name;
|
2006-05-30 21:01:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void bx_param_c::set_description(const char *text)
|
|
|
|
{
|
|
|
|
delete [] this->description;
|
|
|
|
if (text) {
|
|
|
|
this->description = new char[strlen(text)+1];
|
|
|
|
strcpy(this->description, text);
|
|
|
|
} else {
|
|
|
|
this->description = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bx_param_c::set_label(const char *text)
|
|
|
|
{
|
|
|
|
delete [] this->label;
|
|
|
|
if (text) {
|
|
|
|
this->label = new char[strlen(text)+1];
|
|
|
|
strcpy(this->label, text);
|
|
|
|
} else {
|
|
|
|
this->label = NULL;
|
|
|
|
}
|
2006-05-30 02:33:38 +04:00
|
|
|
}
|
|
|
|
|
2006-06-04 11:55:34 +04:00
|
|
|
void bx_param_c::set_ask_format(const char *format)
|
|
|
|
{
|
|
|
|
delete [] this->ask_format;
|
|
|
|
if (format) {
|
|
|
|
this->ask_format = new char[strlen(format)+1];
|
|
|
|
strcpy(this->ask_format, format);
|
|
|
|
} else {
|
|
|
|
this->ask_format = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-05 23:06:36 +04:00
|
|
|
void bx_param_c::set_group(const char *group)
|
|
|
|
{
|
|
|
|
delete [] this->group_name;
|
|
|
|
if (group) {
|
|
|
|
this->group_name = new char[strlen(group)+1];
|
|
|
|
strcpy(this->group_name, group);
|
|
|
|
} else {
|
|
|
|
this->group_name = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 15:05:24 +03:00
|
|
|
int bx_param_c::get_param_path(char *path_out, int maxlen)
|
|
|
|
{
|
|
|
|
if ((get_parent() == NULL) || (get_parent() == root_param)) {
|
|
|
|
// Start with an empty string.
|
|
|
|
// Never print the name of the root param.
|
|
|
|
path_out[0] = 0;
|
|
|
|
} else {
|
|
|
|
// build path of the parent, add a period, add path of this node
|
|
|
|
if (get_parent()->get_param_path(path_out, maxlen) > 0) {
|
|
|
|
strncat(path_out, ".", maxlen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strncat(path_out, name, maxlen);
|
|
|
|
return strlen(path_out);
|
|
|
|
}
|
|
|
|
|
2006-05-29 23:57:12 +04:00
|
|
|
const char* bx_param_c::set_default_format(const char *f)
|
|
|
|
{
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
const char *old = default_text_format;
|
2008-02-06 01:57:43 +03:00
|
|
|
default_text_format = f;
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
2006-02-28 17:02:06 +03:00
|
|
|
bx_param_num_c::bx_param_num_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2006-05-30 21:01:27 +04:00
|
|
|
const char *label,
|
|
|
|
const char *description,
|
2006-04-22 22:14:55 +04:00
|
|
|
Bit64s min, Bit64s max, Bit64s initial_val,
|
|
|
|
bx_bool is_shadow)
|
2006-05-30 21:01:27 +04:00
|
|
|
: bx_param_c(SIM->gen_param_id(), name, label, description)
|
2006-02-17 00:44:17 +03:00
|
|
|
{
|
2006-02-28 17:02:06 +03:00
|
|
|
set_type(BXT_PARAM_NUM);
|
2006-02-17 00:44:17 +03:00
|
|
|
this->min = min;
|
|
|
|
this->max = max;
|
|
|
|
this->initial_val = initial_val;
|
|
|
|
this->val.number = initial_val;
|
|
|
|
this->handler = NULL;
|
2006-05-27 18:02:34 +04:00
|
|
|
this->save_handler = NULL;
|
|
|
|
this->restore_handler = NULL;
|
2006-02-28 17:02:06 +03:00
|
|
|
this->enable_handler = NULL;
|
2006-02-17 00:44:17 +03:00
|
|
|
this->base = default_base;
|
2006-04-22 22:14:55 +04:00
|
|
|
this->is_shadow = is_shadow;
|
2006-02-17 00:44:17 +03:00
|
|
|
// dependent_list must be initialized before the set(),
|
|
|
|
// because set calls update_dependents().
|
|
|
|
dependent_list = NULL;
|
2006-04-22 22:14:55 +04:00
|
|
|
if (!is_shadow) {
|
|
|
|
set(initial_val);
|
|
|
|
}
|
2006-03-06 21:50:55 +03:00
|
|
|
if (parent) {
|
|
|
|
BX_ASSERT(parent->get_type() == BXT_LIST);
|
|
|
|
this->parent = (bx_list_c *)parent;
|
|
|
|
this->parent->add(this);
|
|
|
|
}
|
2006-02-17 00:44:17 +03:00
|
|
|
}
|
|
|
|
|
2006-05-23 01:29:54 +04:00
|
|
|
Bit32u bx_param_num_c::default_base = BASE_DEC;
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
|
2006-05-29 23:57:12 +04:00
|
|
|
Bit32u bx_param_num_c::set_default_base(Bit32u val)
|
|
|
|
{
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
Bit32u old = default_base;
|
2008-02-06 01:57:43 +03:00
|
|
|
default_base = val;
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
void bx_param_num_c::set_handler(param_event_handler handler)
|
2008-02-06 01:57:43 +03:00
|
|
|
{
|
|
|
|
this->handler = handler;
|
2001-06-21 18:37:55 +04:00
|
|
|
// now that there's a handler, call set once to run the handler immediately
|
|
|
|
//set (get ());
|
|
|
|
}
|
|
|
|
|
2006-05-27 18:02:34 +04:00
|
|
|
void bx_param_num_c::set_sr_handlers(void *devptr, param_sr_handler save, param_sr_handler restore)
|
|
|
|
{
|
2008-02-06 01:57:43 +03:00
|
|
|
this->sr_devptr = devptr;
|
|
|
|
this->save_handler = save;
|
|
|
|
this->restore_handler = restore;
|
2006-05-27 18:02:34 +04:00
|
|
|
}
|
|
|
|
|
2007-10-14 23:04:51 +04:00
|
|
|
void bx_param_num_c::set_dependent_list(bx_list_c *l)
|
|
|
|
{
|
2006-02-26 22:11:20 +03:00
|
|
|
dependent_list = l;
|
|
|
|
update_dependents();
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
Bit64s bx_param_num_c::get64()
|
2001-06-16 03:52:34 +04:00
|
|
|
{
|
2006-05-27 18:02:34 +04:00
|
|
|
if (save_handler) {
|
|
|
|
return (*save_handler)(sr_devptr, this, val.number);
|
|
|
|
}
|
2001-06-19 18:20:24 +04:00
|
|
|
if (handler) {
|
|
|
|
// the handler can decide what value to return and/or do some side effect
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
return (*handler)(this, 0, val.number);
|
2001-06-19 18:20:24 +04:00
|
|
|
} else {
|
|
|
|
// just return the value
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
return val.number;
|
2001-06-19 18:20:24 +04:00
|
|
|
}
|
2001-06-16 03:52:34 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
void bx_param_num_c::set(Bit64s newval)
|
2001-06-16 03:52:34 +04:00
|
|
|
{
|
2001-06-19 18:20:24 +04:00
|
|
|
if (handler) {
|
|
|
|
// the handler can override the new value and/or perform some side effect
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
val.number = newval;
|
2001-09-28 10:02:12 +04:00
|
|
|
(*handler)(this, 1, newval);
|
2001-06-19 18:20:24 +04:00
|
|
|
} else {
|
|
|
|
// just set the value. This code does not check max/min.
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
val.number = newval;
|
|
|
|
}
|
2006-05-27 18:02:34 +04:00
|
|
|
if (restore_handler) {
|
|
|
|
val.number = newval;
|
|
|
|
(*restore_handler)(sr_devptr, this, newval);
|
|
|
|
}
|
2003-10-11 14:43:52 +04:00
|
|
|
if ((val.number < min || val.number > max) && (Bit64u)max != BX_MAX_BIT64U)
|
2006-03-07 20:54:27 +03:00
|
|
|
BX_PANIC(("numerical parameter '%s' was set to " FMT_LL "d, which is out of range " FMT_LL "d to " FMT_LL "d", get_name (), val.number, min, max));
|
2006-02-26 22:11:20 +03:00
|
|
|
if (dependent_list != NULL) update_dependents();
|
2002-09-17 08:47:55 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
void bx_param_num_c::set_range(Bit64u min, Bit64u max)
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
{
|
|
|
|
this->min = min;
|
|
|
|
this->max = max;
|
|
|
|
}
|
|
|
|
|
2006-05-29 23:57:12 +04:00
|
|
|
void bx_param_num_c::set_initial_val(Bit64s initial_val)
|
2008-02-06 01:57:43 +03:00
|
|
|
{
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
this->val.number = this->initial_val = initial_val;
|
|
|
|
}
|
|
|
|
|
2006-02-26 22:11:20 +03:00
|
|
|
void bx_param_num_c::update_dependents()
|
2002-09-17 08:47:55 +04:00
|
|
|
{
|
|
|
|
if (dependent_list) {
|
2002-09-23 00:56:12 +04:00
|
|
|
int en = val.number && enabled;
|
2006-02-26 22:11:20 +03:00
|
|
|
for (int i=0; i<dependent_list->get_size(); i++) {
|
|
|
|
bx_param_c *param = dependent_list->get(i);
|
2002-09-23 00:56:12 +04:00
|
|
|
if (param != this)
|
2009-03-17 00:07:44 +03:00
|
|
|
param->set_enabled(en);
|
2002-09-23 00:56:12 +04:00
|
|
|
}
|
2002-09-17 08:47:55 +04:00
|
|
|
}
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 23:32:07 +03:00
|
|
|
void bx_param_num_c::set_enabled(int en)
|
2002-09-23 00:56:12 +04:00
|
|
|
{
|
2003-08-10 02:17:38 +04:00
|
|
|
// The enable handler may wish to allow/disallow the action
|
|
|
|
if (enable_handler) {
|
2006-03-07 20:54:27 +03:00
|
|
|
en = (*enable_handler)(this, en);
|
2006-05-28 01:37:36 +04:00
|
|
|
}
|
2006-03-07 20:54:27 +03:00
|
|
|
bx_param_c::set_enabled(en);
|
|
|
|
update_dependents();
|
2002-09-23 00:56:12 +04:00
|
|
|
}
|
|
|
|
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
// Signed 64 bit
|
2006-03-07 23:32:07 +03:00
|
|
|
bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit64s *ptr_to_real_val,
|
2006-04-22 22:14:55 +04:00
|
|
|
int base,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit8u highbit,
|
|
|
|
Bit8u lowbit)
|
2006-05-27 18:02:34 +04:00
|
|
|
: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT64S, BX_MAX_BIT64S, *ptr_to_real_val, 1)
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
{
|
2006-04-22 22:14:55 +04:00
|
|
|
this->varsize = 64;
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
this->lowbit = lowbit;
|
2006-05-14 19:47:37 +04:00
|
|
|
this->mask = ((BX_MAX_BIT64S >> (63 - (highbit - lowbit))) << lowbit);
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
val.p64bit = ptr_to_real_val;
|
2006-05-23 01:29:54 +04:00
|
|
|
if (base == BASE_HEX) {
|
2006-04-22 22:14:55 +04:00
|
|
|
this->base = base;
|
2006-05-29 23:57:12 +04:00
|
|
|
this->text_format = "0x"FMT_LL"x";
|
2006-04-22 22:14:55 +04:00
|
|
|
}
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unsigned 64 bit
|
2006-03-07 23:32:07 +03:00
|
|
|
bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit64u *ptr_to_real_val,
|
2006-04-22 22:14:55 +04:00
|
|
|
int base,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit8u highbit,
|
|
|
|
Bit8u lowbit)
|
2006-05-27 18:02:34 +04:00
|
|
|
: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT64U, BX_MAX_BIT64U, *ptr_to_real_val, 1)
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
{
|
2006-04-22 22:14:55 +04:00
|
|
|
this->varsize = 64;
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
this->lowbit = lowbit;
|
2006-05-14 19:47:37 +04:00
|
|
|
this->mask = ((BX_MAX_BIT64U >> (63 - (highbit - lowbit))) << lowbit);
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
val.p64bit = (Bit64s*) ptr_to_real_val;
|
2006-05-23 01:29:54 +04:00
|
|
|
if (base == BASE_HEX) {
|
2006-04-22 22:14:55 +04:00
|
|
|
this->base = base;
|
2006-05-29 23:57:12 +04:00
|
|
|
this->text_format = "0x"FMT_LL"x";
|
2006-04-22 22:14:55 +04:00
|
|
|
}
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Signed 32 bit
|
2006-03-07 23:32:07 +03:00
|
|
|
bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2002-09-11 07:53:48 +04:00
|
|
|
Bit32s *ptr_to_real_val,
|
2006-04-22 22:14:55 +04:00
|
|
|
int base,
|
2002-09-11 07:53:48 +04:00
|
|
|
Bit8u highbit,
|
|
|
|
Bit8u lowbit)
|
2006-05-27 18:02:34 +04:00
|
|
|
: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT32S, BX_MAX_BIT32S, *ptr_to_real_val, 1)
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
{
|
2006-05-29 23:57:12 +04:00
|
|
|
this->varsize = 32;
|
2002-09-11 07:53:48 +04:00
|
|
|
this->lowbit = lowbit;
|
2006-05-14 19:47:37 +04:00
|
|
|
this->mask = ((BX_MAX_BIT32S >> (31 - (highbit - lowbit))) << lowbit);
|
2002-09-11 07:53:48 +04:00
|
|
|
val.p32bit = ptr_to_real_val;
|
2006-05-23 01:29:54 +04:00
|
|
|
if (base == BASE_HEX) {
|
2006-04-22 22:14:55 +04:00
|
|
|
this->base = base;
|
|
|
|
this->text_format = "0x%08x";
|
|
|
|
}
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
}
|
|
|
|
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
// Unsigned 32 bit
|
2006-03-07 20:54:27 +03:00
|
|
|
bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2006-03-07 20:54:27 +03:00
|
|
|
Bit32u *ptr_to_real_val,
|
2006-04-22 22:14:55 +04:00
|
|
|
int base,
|
2006-03-07 20:54:27 +03:00
|
|
|
Bit8u highbit,
|
|
|
|
Bit8u lowbit)
|
2006-05-27 18:02:34 +04:00
|
|
|
: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT32U, BX_MAX_BIT32U, *ptr_to_real_val, 1)
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
{
|
2002-09-11 07:53:48 +04:00
|
|
|
this->varsize = 32;
|
|
|
|
this->lowbit = lowbit;
|
2006-05-14 19:47:37 +04:00
|
|
|
this->mask = ((BX_MAX_BIT32U >> (31 - (highbit - lowbit))) << lowbit);
|
2002-09-11 07:53:48 +04:00
|
|
|
val.p32bit = (Bit32s*) ptr_to_real_val;
|
2006-05-23 01:29:54 +04:00
|
|
|
if (base == BASE_HEX) {
|
2006-04-22 22:14:55 +04:00
|
|
|
this->base = base;
|
|
|
|
this->text_format = "0x%08x";
|
|
|
|
}
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
}
|
|
|
|
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
// Signed 16 bit
|
2006-03-07 23:32:07 +03:00
|
|
|
bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit16s *ptr_to_real_val,
|
2006-04-22 22:14:55 +04:00
|
|
|
int base,
|
2002-09-11 07:53:48 +04:00
|
|
|
Bit8u highbit,
|
|
|
|
Bit8u lowbit)
|
2006-05-27 18:02:34 +04:00
|
|
|
: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT16S, BX_MAX_BIT16S, *ptr_to_real_val, 1)
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
{
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
this->varsize = 16;
|
2002-09-11 07:53:48 +04:00
|
|
|
this->lowbit = lowbit;
|
2006-05-14 19:47:37 +04:00
|
|
|
this->mask = ((BX_MAX_BIT16S >> (15 - (highbit - lowbit))) << lowbit);
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
val.p16bit = ptr_to_real_val;
|
2006-05-23 01:29:54 +04:00
|
|
|
if (base == BASE_HEX) {
|
2006-04-22 22:14:55 +04:00
|
|
|
this->base = base;
|
|
|
|
this->text_format = "0x%04x";
|
|
|
|
}
|
2002-09-11 07:53:48 +04:00
|
|
|
}
|
|
|
|
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
// Unsigned 16 bit
|
2006-03-07 23:32:07 +03:00
|
|
|
bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2002-09-11 07:53:48 +04:00
|
|
|
Bit16u *ptr_to_real_val,
|
2006-04-22 22:14:55 +04:00
|
|
|
int base,
|
2002-09-11 07:53:48 +04:00
|
|
|
Bit8u highbit,
|
|
|
|
Bit8u lowbit)
|
2006-05-27 18:02:34 +04:00
|
|
|
: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT16U, BX_MAX_BIT16U, *ptr_to_real_val, 1)
|
2002-09-11 07:53:48 +04:00
|
|
|
{
|
|
|
|
this->varsize = 16;
|
|
|
|
this->lowbit = lowbit;
|
2006-05-14 19:47:37 +04:00
|
|
|
this->mask = ((BX_MAX_BIT16U >> (15 - (highbit - lowbit))) << lowbit);
|
2002-09-11 07:53:48 +04:00
|
|
|
val.p16bit = (Bit16s*) ptr_to_real_val;
|
2006-05-23 01:29:54 +04:00
|
|
|
if (base == BASE_HEX) {
|
2006-04-22 22:14:55 +04:00
|
|
|
this->base = base;
|
|
|
|
this->text_format = "0x%04x";
|
|
|
|
}
|
2002-09-11 07:53:48 +04:00
|
|
|
}
|
|
|
|
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
// Signed 8 bit
|
2006-03-07 23:32:07 +03:00
|
|
|
bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit8s *ptr_to_real_val,
|
2006-04-22 22:14:55 +04:00
|
|
|
int base,
|
2002-09-11 07:53:48 +04:00
|
|
|
Bit8u highbit,
|
|
|
|
Bit8u lowbit)
|
2006-05-27 18:02:34 +04:00
|
|
|
: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT8S, BX_MAX_BIT8S, *ptr_to_real_val, 1)
|
2002-09-11 07:53:48 +04:00
|
|
|
{
|
2006-05-29 23:57:12 +04:00
|
|
|
this->varsize = 8;
|
2002-09-11 07:53:48 +04:00
|
|
|
this->lowbit = lowbit;
|
2006-05-14 19:47:37 +04:00
|
|
|
this->mask = ((BX_MAX_BIT8S >> (7 - (highbit - lowbit))) << lowbit);
|
2002-09-11 07:53:48 +04:00
|
|
|
this->mask = (1 << (highbit - lowbit)) - 1;
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
val.p8bit = ptr_to_real_val;
|
2006-05-23 01:29:54 +04:00
|
|
|
if (base == BASE_HEX) {
|
2006-04-22 22:14:55 +04:00
|
|
|
this->base = base;
|
|
|
|
this->text_format = "0x%02x";
|
|
|
|
}
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
}
|
|
|
|
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
// Unsigned 8 bit
|
2006-03-07 23:32:07 +03:00
|
|
|
bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit8u *ptr_to_real_val,
|
2006-04-22 22:14:55 +04:00
|
|
|
int base,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit8u highbit,
|
|
|
|
Bit8u lowbit)
|
2006-05-27 18:02:34 +04:00
|
|
|
: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT8U, BX_MAX_BIT8U, *ptr_to_real_val, 1)
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
{
|
|
|
|
this->varsize = 8;
|
|
|
|
this->lowbit = lowbit;
|
2006-05-14 19:47:37 +04:00
|
|
|
this->mask = ((BX_MAX_BIT8U >> (7 - (highbit - lowbit))) << lowbit);
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
val.p8bit = (Bit8s*) ptr_to_real_val;
|
2006-05-23 01:29:54 +04:00
|
|
|
if (base == BASE_HEX) {
|
2006-04-22 22:14:55 +04:00
|
|
|
this->base = base;
|
|
|
|
this->text_format = "0x%02x";
|
|
|
|
}
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
}
|
|
|
|
|
2006-05-29 23:57:12 +04:00
|
|
|
Bit64s bx_shadow_num_c::get64()
|
|
|
|
{
|
2002-11-19 12:27:39 +03:00
|
|
|
Bit64u current = 0;
|
2002-09-11 07:53:48 +04:00
|
|
|
switch (varsize) {
|
|
|
|
case 8: current = *(val.p8bit); break;
|
|
|
|
case 16: current = *(val.p16bit); break;
|
|
|
|
case 32: current = *(val.p32bit); break;
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
case 64: current = *(val.p64bit); break;
|
|
|
|
default: BX_PANIC(("unsupported varsize %d", varsize));
|
2002-09-11 07:53:48 +04:00
|
|
|
}
|
|
|
|
current = (current >> lowbit) & mask;
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
if (handler) {
|
|
|
|
// the handler can decide what value to return and/or do some side effect
|
2002-09-11 07:53:48 +04:00
|
|
|
return (*handler)(this, 0, current) & mask;
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
} else {
|
|
|
|
// just return the value
|
2002-09-11 07:53:48 +04:00
|
|
|
return current;
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
void bx_shadow_num_c::set(Bit64s newval)
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
{
|
2002-11-19 12:27:39 +03:00
|
|
|
Bit64u tmp = 0;
|
2006-04-22 22:14:55 +04:00
|
|
|
if (((newval < min) || (newval > max)) && (min != BX_MIN_BIT64S) && ((Bit64u)max != BX_MAX_BIT64U))
|
2008-09-20 01:31:08 +04:00
|
|
|
BX_PANIC(("numerical parameter %s was set to " FMT_LL "d, which is out of range " FMT_LL "d to " FMT_LL "d", get_name (), newval, min, max));
|
2002-09-11 07:53:48 +04:00
|
|
|
switch (varsize) {
|
2008-02-06 01:57:43 +03:00
|
|
|
case 8:
|
2006-05-01 22:24:47 +04:00
|
|
|
tmp = *(val.p8bit) & ~(mask << lowbit);
|
2002-09-11 07:53:48 +04:00
|
|
|
tmp |= (newval & mask) << lowbit;
|
2003-06-07 23:16:55 +04:00
|
|
|
*(val.p8bit) = (Bit8s)tmp;
|
2002-09-11 07:53:48 +04:00
|
|
|
break;
|
|
|
|
case 16:
|
2006-05-01 22:24:47 +04:00
|
|
|
tmp = *(val.p16bit) & ~(mask << lowbit);
|
2002-09-11 07:53:48 +04:00
|
|
|
tmp |= (newval & mask) << lowbit;
|
2003-06-07 23:16:55 +04:00
|
|
|
*(val.p16bit) = (Bit16s)tmp;
|
2002-09-11 07:53:48 +04:00
|
|
|
break;
|
|
|
|
case 32:
|
2006-05-01 22:24:47 +04:00
|
|
|
tmp = *(val.p32bit) & ~(mask << lowbit);
|
2002-09-11 07:53:48 +04:00
|
|
|
tmp |= (newval & mask) << lowbit;
|
2003-06-07 23:16:55 +04:00
|
|
|
*(val.p32bit) = (Bit32s)tmp;
|
2002-09-11 07:53:48 +04:00
|
|
|
break;
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
case 64:
|
2006-05-01 22:24:47 +04:00
|
|
|
tmp = *(val.p64bit) & ~(mask << lowbit);
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
tmp |= (newval & mask) << lowbit;
|
2006-05-29 23:57:12 +04:00
|
|
|
*(val.p64bit) = (Bit64s)tmp;
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
break;
|
2008-02-06 01:57:43 +03:00
|
|
|
default:
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
BX_PANIC(("unsupported varsize %d", varsize));
|
2002-09-11 07:53:48 +04:00
|
|
|
}
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
if (handler) {
|
|
|
|
// the handler can override the new value and/or perform some side effect
|
2002-09-11 07:53:48 +04:00
|
|
|
(*handler)(this, 1, tmp);
|
2001-06-19 18:20:24 +04:00
|
|
|
}
|
2001-06-16 23:29:59 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
void bx_shadow_num_c::reset()
|
2006-02-17 00:44:17 +03:00
|
|
|
{
|
2006-03-07 20:54:27 +03:00
|
|
|
BX_PANIC(("reset not supported on bx_shadow_num_c yet"));
|
2006-02-17 00:44:17 +03:00
|
|
|
}
|
|
|
|
|
2006-02-18 19:53:18 +03:00
|
|
|
bx_param_bool_c::bx_param_bool_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2006-05-30 21:01:27 +04:00
|
|
|
const char *label,
|
|
|
|
const char *description,
|
2006-05-01 22:24:47 +04:00
|
|
|
Bit64s initial_val,
|
|
|
|
bx_bool is_shadow)
|
|
|
|
: bx_param_num_c(parent, name, label, description, 0, 1, initial_val, is_shadow)
|
2006-02-18 19:53:18 +03:00
|
|
|
{
|
|
|
|
set_type(BXT_PARAM_BOOL);
|
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
bx_shadow_bool_c::bx_shadow_bool_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2006-05-30 21:01:27 +04:00
|
|
|
const char *label,
|
2006-03-07 20:54:27 +03:00
|
|
|
bx_bool *ptr_to_real_val,
|
|
|
|
Bit8u bitnum)
|
2006-05-01 22:24:47 +04:00
|
|
|
: bx_param_bool_c(parent, name, label, NULL, (Bit64s) *ptr_to_real_val, 1)
|
2006-03-07 20:54:27 +03:00
|
|
|
{
|
|
|
|
val.pbool = ptr_to_real_val;
|
|
|
|
this->bitnum = bitnum;
|
|
|
|
}
|
|
|
|
|
2006-05-14 19:47:37 +04:00
|
|
|
bx_shadow_bool_c::bx_shadow_bool_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2006-05-14 19:47:37 +04:00
|
|
|
bx_bool *ptr_to_real_val,
|
|
|
|
Bit8u bitnum)
|
|
|
|
: bx_param_bool_c(parent, name, NULL, NULL, (Bit64s) *ptr_to_real_val, 1)
|
|
|
|
{
|
|
|
|
val.pbool = ptr_to_real_val;
|
|
|
|
this->bitnum = bitnum;
|
|
|
|
}
|
|
|
|
|
2006-05-29 23:57:12 +04:00
|
|
|
Bit64s bx_shadow_bool_c::get64()
|
|
|
|
{
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
if (handler) {
|
|
|
|
// the handler can decide what value to return and/or do some side effect
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit64s ret = (*handler)(this, 0, (Bit64s) *(val.pbool));
|
2002-09-11 07:53:48 +04:00
|
|
|
return (ret>>bitnum) & 1;
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
} else {
|
|
|
|
// just return the value
|
2002-09-11 07:53:48 +04:00
|
|
|
return (*(val.pbool)) & 1;
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
void bx_shadow_bool_c::set(Bit64s newval)
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
{
|
2002-09-11 07:53:48 +04:00
|
|
|
// only change the bitnum bit
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
Bit64s tmp = (newval&1) << bitnum;
|
2002-09-11 07:53:48 +04:00
|
|
|
*(val.pbool) &= ~tmp;
|
|
|
|
*(val.pbool) |= tmp;
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
if (handler) {
|
|
|
|
// the handler can override the new value and/or perform some side effect
|
2002-09-11 07:53:48 +04:00
|
|
|
(*handler)(this, 1, newval&1);
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-07 20:54:27 +03:00
|
|
|
bx_param_enum_c::bx_param_enum_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2006-05-30 21:01:27 +04:00
|
|
|
const char *label,
|
|
|
|
const char *description,
|
2007-10-25 03:09:59 +04:00
|
|
|
const char **choices,
|
2006-02-19 18:43:03 +03:00
|
|
|
Bit64s initial_val,
|
|
|
|
Bit64s value_base)
|
|
|
|
: bx_param_num_c(parent, name, label, description, value_base, BX_MAX_BIT64S, initial_val)
|
|
|
|
{
|
|
|
|
set_type(BXT_PARAM_ENUM);
|
|
|
|
this->choices = choices;
|
|
|
|
// count number of choices, set max
|
2007-10-25 03:09:59 +04:00
|
|
|
const char **p = choices;
|
2006-02-19 18:43:03 +03:00
|
|
|
while (*p != NULL) p++;
|
|
|
|
this->min = value_base;
|
|
|
|
// now that the max is known, replace the BX_MAX_BIT64S sent to the parent
|
|
|
|
// class constructor with the real max.
|
|
|
|
this->max = value_base + (p - choices - 1);
|
2009-03-17 00:07:44 +03:00
|
|
|
this->deps_bitmap = NULL;
|
2006-02-19 18:43:03 +03:00
|
|
|
set(initial_val);
|
2001-06-20 18:01:39 +04:00
|
|
|
}
|
|
|
|
|
2009-03-17 00:07:44 +03:00
|
|
|
bx_param_enum_c::~bx_param_enum_c()
|
|
|
|
{
|
|
|
|
if (deps_bitmap != NULL) {
|
|
|
|
free(deps_bitmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void bx_param_enum_c::set(Bit64s val)
|
|
|
|
{
|
|
|
|
bx_param_num_c::set(val);
|
|
|
|
update_dependents();
|
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
int bx_param_enum_c::find_by_name(const char *string)
|
2002-10-25 01:07:56 +04:00
|
|
|
{
|
2007-10-25 03:09:59 +04:00
|
|
|
const char **p;
|
2002-10-25 01:07:56 +04:00
|
|
|
for (p=&choices[0]; *p; p++) {
|
2006-02-25 01:35:46 +03:00
|
|
|
if (!strcmp(string, *p))
|
2002-10-25 01:07:56 +04:00
|
|
|
return p-choices;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-04-07 00:42:51 +04:00
|
|
|
bx_bool bx_param_enum_c::set_by_name(const char *string)
|
2002-10-25 01:07:56 +04:00
|
|
|
{
|
2006-02-25 01:35:46 +03:00
|
|
|
int n = find_by_name(string);
|
2006-04-07 00:42:51 +04:00
|
|
|
if (n<0) return 0;
|
2006-02-25 01:35:46 +03:00
|
|
|
set(n + min);
|
2006-04-07 00:42:51 +04:00
|
|
|
return 1;
|
2002-10-25 01:07:56 +04:00
|
|
|
}
|
|
|
|
|
2009-03-17 22:37:20 +03:00
|
|
|
void bx_param_enum_c::set_dependent_list(bx_list_c *l, bx_bool enable_all)
|
2009-03-17 00:07:44 +03:00
|
|
|
{
|
|
|
|
dependent_list = l;
|
|
|
|
deps_bitmap = (Bit64u*)malloc(sizeof(Bit64u) * (max - min + 1));
|
|
|
|
for (int i=0; i<(max-min+1); i++) {
|
2009-03-17 22:37:20 +03:00
|
|
|
if (enable_all) {
|
|
|
|
deps_bitmap[i] = (1 << (l->get_size())) - 1;
|
|
|
|
} else {
|
|
|
|
deps_bitmap[i] = 0;
|
|
|
|
}
|
2009-03-17 00:07:44 +03:00
|
|
|
}
|
|
|
|
update_dependents();
|
|
|
|
}
|
|
|
|
|
|
|
|
void bx_param_enum_c::set_dependent_bitmap(Bit64s value, Bit64u bitmap)
|
|
|
|
{
|
|
|
|
if (deps_bitmap != NULL) {
|
|
|
|
deps_bitmap[value - min] = bitmap;
|
|
|
|
}
|
2009-03-23 22:05:16 +03:00
|
|
|
update_dependents();
|
2009-03-17 00:07:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Bit64u bx_param_enum_c::get_dependent_bitmap(Bit64s value)
|
|
|
|
{
|
|
|
|
if (deps_bitmap != NULL) {
|
|
|
|
return deps_bitmap[value - min];
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void bx_param_enum_c::update_dependents()
|
|
|
|
{
|
|
|
|
if ((dependent_list != NULL) && (deps_bitmap != NULL)) {
|
|
|
|
Bit64u en_bmap = deps_bitmap[val.number - min];
|
|
|
|
Bit64u mask = 0x1;
|
|
|
|
for (int i=0; i<dependent_list->get_size(); i++) {
|
|
|
|
int en = (en_bmap & mask) && enabled;
|
|
|
|
bx_param_c *param = dependent_list->get(i);
|
|
|
|
if (param != this)
|
|
|
|
param->set_enabled(en);
|
|
|
|
mask <<= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-06 21:50:55 +03:00
|
|
|
bx_param_string_c::bx_param_string_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2006-05-30 21:01:27 +04:00
|
|
|
const char *label,
|
|
|
|
const char *description,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *initial_val,
|
2006-02-17 00:44:17 +03:00
|
|
|
int maxsize)
|
2006-05-30 21:01:27 +04:00
|
|
|
: bx_param_c(SIM->gen_param_id(), name, label, description)
|
2006-02-17 00:44:17 +03:00
|
|
|
{
|
2006-03-06 21:50:55 +03:00
|
|
|
set_type(BXT_PARAM_STRING);
|
2008-08-19 20:43:07 +04:00
|
|
|
int initial_val_size = strlen(initial_val) + 1;
|
2009-01-02 17:16:16 +03:00
|
|
|
if (maxsize < 0) {
|
2008-08-19 20:43:07 +04:00
|
|
|
maxsize = initial_val_size;
|
2009-01-02 17:16:16 +03:00
|
|
|
} else if (initial_val_size > maxsize) {
|
|
|
|
initial_val_size = maxsize;
|
|
|
|
}
|
2006-02-17 00:44:17 +03:00
|
|
|
this->val = new char[maxsize];
|
|
|
|
this->initial_val = new char[maxsize];
|
|
|
|
this->handler = NULL;
|
|
|
|
this->enable_handler = NULL;
|
|
|
|
this->maxsize = maxsize;
|
2008-08-19 20:43:07 +04:00
|
|
|
strncpy(this->val, initial_val, initial_val_size);
|
|
|
|
if (maxsize > initial_val_size)
|
|
|
|
memset(this->val + initial_val_size, 0, maxsize - initial_val_size);
|
2006-03-06 21:50:55 +03:00
|
|
|
strncpy(this->initial_val, initial_val, maxsize);
|
2009-03-16 00:16:17 +03:00
|
|
|
this->options = 0;
|
2006-03-06 21:50:55 +03:00
|
|
|
set(initial_val);
|
|
|
|
if (parent) {
|
|
|
|
BX_ASSERT(parent->get_type() == BXT_LIST);
|
|
|
|
this->parent = (bx_list_c *)parent;
|
|
|
|
this->parent->add(this);
|
|
|
|
}
|
2002-04-18 04:22:20 +04:00
|
|
|
}
|
|
|
|
|
2006-03-06 21:50:55 +03:00
|
|
|
bx_param_filename_c::bx_param_filename_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2006-05-30 21:01:27 +04:00
|
|
|
const char *label,
|
|
|
|
const char *description,
|
|
|
|
const char *initial_val,
|
2006-02-17 00:44:17 +03:00
|
|
|
int maxsize)
|
2006-02-18 19:53:18 +03:00
|
|
|
: bx_param_string_c(parent, name, label, description, initial_val, maxsize)
|
2006-02-17 00:44:17 +03:00
|
|
|
{
|
2009-03-16 00:16:17 +03:00
|
|
|
set_options(IS_FILENAME);
|
|
|
|
ext = NULL;
|
2006-02-17 00:44:17 +03:00
|
|
|
}
|
|
|
|
|
2006-03-06 21:50:55 +03:00
|
|
|
bx_param_string_c::~bx_param_string_c()
|
2001-12-21 22:33:18 +03:00
|
|
|
{
|
2006-05-30 21:01:27 +04:00
|
|
|
if (val != NULL) delete [] val;
|
|
|
|
if (initial_val != NULL) delete [] initial_val;
|
2001-12-21 22:33:18 +03:00
|
|
|
}
|
|
|
|
|
2006-05-23 01:29:54 +04:00
|
|
|
void bx_param_string_c::reset()
|
|
|
|
{
|
2009-01-02 17:16:16 +03:00
|
|
|
set(initial_val);
|
2001-06-16 23:29:59 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
void bx_param_string_c::set_handler(param_string_event_handler handler)
|
2001-06-21 18:37:55 +04:00
|
|
|
{
|
2008-02-06 01:57:43 +03:00
|
|
|
this->handler = handler;
|
2001-06-21 18:37:55 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
void bx_param_string_c::set_enable_handler(param_enable_handler handler)
|
2008-02-06 01:57:43 +03:00
|
|
|
{
|
|
|
|
this->enable_handler = handler;
|
2003-08-10 02:17:38 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
void bx_param_string_c::set_enabled(int en)
|
2003-08-10 02:17:38 +04:00
|
|
|
{
|
|
|
|
// The enable handler may wish to allow/disallow the action
|
|
|
|
if (enable_handler) {
|
2006-03-06 21:50:55 +03:00
|
|
|
en = (*enable_handler)(this, en);
|
2006-05-28 01:37:36 +04:00
|
|
|
}
|
2006-03-06 21:50:55 +03:00
|
|
|
bx_param_c::set_enabled(en);
|
2003-08-10 02:17:38 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
Bit32s bx_param_string_c::get(char *buf, int len)
|
2001-06-16 23:29:59 +04:00
|
|
|
{
|
2009-03-16 00:16:17 +03:00
|
|
|
if (options & RAW_BYTES)
|
2006-03-06 21:50:55 +03:00
|
|
|
memcpy(buf, val, len);
|
2001-06-21 23:27:05 +04:00
|
|
|
else
|
2006-03-06 21:50:55 +03:00
|
|
|
strncpy(buf, val, len);
|
2001-06-21 18:37:55 +04:00
|
|
|
if (handler) {
|
|
|
|
// the handler can choose to replace the value in val/len. Also its
|
|
|
|
// return value is passed back as the return value of get.
|
2009-01-05 00:46:20 +03:00
|
|
|
(*handler)(this, 0, buf, buf, len);
|
2001-06-21 18:37:55 +04:00
|
|
|
}
|
2001-06-16 23:29:59 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-13 21:55:53 +03:00
|
|
|
void bx_param_string_c::set(const char *buf)
|
2001-06-16 23:29:59 +04:00
|
|
|
{
|
2009-01-05 00:46:20 +03:00
|
|
|
char *oldval = new char[maxsize];
|
|
|
|
|
2009-03-16 00:16:17 +03:00
|
|
|
if (options & RAW_BYTES) {
|
2009-01-05 00:46:20 +03:00
|
|
|
memcpy(oldval, val, maxsize);
|
2006-03-06 21:50:55 +03:00
|
|
|
memcpy(val, buf, maxsize);
|
2009-01-05 00:46:20 +03:00
|
|
|
} else {
|
|
|
|
strncpy(oldval, val, maxsize);
|
|
|
|
oldval[maxsize - 1] = 0;
|
2006-03-06 21:50:55 +03:00
|
|
|
strncpy(val, buf, maxsize);
|
2006-03-13 21:55:53 +03:00
|
|
|
val[maxsize - 1] = 0;
|
|
|
|
}
|
2001-09-28 10:02:12 +04:00
|
|
|
if (handler) {
|
|
|
|
// the handler can return a different char* to be copied into the value
|
2009-01-05 00:46:20 +03:00
|
|
|
buf = (*handler)(this, 1, oldval, buf, -1);
|
2001-09-28 10:02:12 +04:00
|
|
|
}
|
2009-01-05 00:46:20 +03:00
|
|
|
delete [] oldval;
|
2001-06-16 03:52:34 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
bx_bool bx_param_string_c::equals(const char *buf)
|
2002-12-12 21:31:20 +03:00
|
|
|
{
|
2009-03-16 00:16:17 +03:00
|
|
|
if (options & RAW_BYTES)
|
2006-03-06 21:50:55 +03:00
|
|
|
return (memcmp(val, buf, maxsize) == 0);
|
2002-12-12 21:31:20 +03:00
|
|
|
else
|
2006-03-06 21:50:55 +03:00
|
|
|
return (strncmp(val, buf, maxsize) == 0);
|
2002-12-12 21:31:20 +03:00
|
|
|
}
|
|
|
|
|
2006-05-30 02:33:38 +04:00
|
|
|
void bx_param_string_c::set_initial_val(const char *buf)
|
|
|
|
{
|
2009-03-16 00:16:17 +03:00
|
|
|
if (options & RAW_BYTES)
|
2006-03-06 21:50:55 +03:00
|
|
|
memcpy(initial_val, buf, maxsize);
|
2005-10-15 14:43:55 +04:00
|
|
|
else
|
2006-03-06 21:50:55 +03:00
|
|
|
strncpy(initial_val, buf, maxsize);
|
|
|
|
set(initial_val);
|
2005-10-15 14:43:55 +04:00
|
|
|
}
|
|
|
|
|
2006-04-15 18:05:18 +04:00
|
|
|
bx_shadow_data_c::bx_shadow_data_c(bx_param_c *parent,
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *name,
|
2006-04-15 18:05:18 +04:00
|
|
|
Bit8u *ptr_to_data,
|
|
|
|
Bit32u data_size)
|
2006-05-14 19:47:37 +04:00
|
|
|
: bx_param_c(SIM->gen_param_id(), name, "")
|
2006-04-15 18:05:18 +04:00
|
|
|
{
|
|
|
|
set_type(BXT_PARAM_DATA);
|
|
|
|
this->data_ptr = ptr_to_data;
|
|
|
|
this->data_size = data_size;
|
|
|
|
if (parent) {
|
|
|
|
BX_ASSERT(parent->get_type() == BXT_LIST);
|
|
|
|
this->parent = (bx_list_c *)parent;
|
|
|
|
this->parent->add(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-07 23:32:07 +03:00
|
|
|
bx_list_c::bx_list_c(bx_param_c *parent, int maxsize)
|
2006-03-08 21:10:41 +03:00
|
|
|
: bx_param_c(SIM->gen_param_id(), "list", "")
|
2001-06-16 03:52:34 +04:00
|
|
|
{
|
2006-02-18 19:53:18 +03:00
|
|
|
set_type(BXT_LIST);
|
2001-06-18 18:11:55 +04:00
|
|
|
this->size = 0;
|
2001-06-19 08:55:01 +04:00
|
|
|
this->maxsize = maxsize;
|
2006-05-30 02:33:38 +04:00
|
|
|
this->list = new bx_param_c* [maxsize];
|
2006-02-17 00:44:17 +03:00
|
|
|
this->parent = NULL;
|
2006-03-07 23:32:07 +03:00
|
|
|
if (parent) {
|
|
|
|
BX_ASSERT(parent->get_type() == BXT_LIST);
|
|
|
|
this->parent = (bx_list_c *)parent;
|
|
|
|
this->parent->add(this);
|
|
|
|
}
|
2006-02-18 19:53:18 +03:00
|
|
|
init("");
|
2001-06-16 03:52:34 +04:00
|
|
|
}
|
|
|
|
|
2006-05-30 02:33:38 +04:00
|
|
|
bx_list_c::bx_list_c(bx_param_c *parent, const char *name, int maxsize)
|
2006-05-14 19:47:37 +04:00
|
|
|
: bx_param_c(SIM->gen_param_id(), name, "")
|
|
|
|
{
|
|
|
|
set_type (BXT_LIST);
|
|
|
|
this->size = 0;
|
|
|
|
this->maxsize = maxsize;
|
2006-05-30 02:33:38 +04:00
|
|
|
this->list = new bx_param_c* [maxsize];
|
2006-05-14 19:47:37 +04:00
|
|
|
this->parent = NULL;
|
|
|
|
if (parent) {
|
|
|
|
BX_ASSERT(parent->get_type() == BXT_LIST);
|
|
|
|
this->parent = (bx_list_c *)parent;
|
|
|
|
this->parent->add(this);
|
|
|
|
}
|
|
|
|
init("");
|
|
|
|
}
|
|
|
|
|
2007-10-25 03:09:59 +04:00
|
|
|
bx_list_c::bx_list_c(bx_param_c *parent, const char *name, const char *title,
|
2006-02-17 00:44:17 +03:00
|
|
|
int maxsize)
|
2006-03-08 21:10:41 +03:00
|
|
|
: bx_param_c(SIM->gen_param_id(), name, "")
|
2006-02-17 00:44:17 +03:00
|
|
|
{
|
|
|
|
set_type (BXT_LIST);
|
|
|
|
this->size = 0;
|
|
|
|
this->maxsize = maxsize;
|
2006-05-30 02:33:38 +04:00
|
|
|
this->list = new bx_param_c* [maxsize];
|
2006-02-17 00:44:17 +03:00
|
|
|
this->parent = NULL;
|
|
|
|
if (parent) {
|
|
|
|
BX_ASSERT(parent->get_type() == BXT_LIST);
|
|
|
|
this->parent = (bx_list_c *)parent;
|
2006-02-26 22:11:20 +03:00
|
|
|
this->parent->add(this);
|
2006-02-17 00:44:17 +03:00
|
|
|
}
|
2006-02-18 19:53:18 +03:00
|
|
|
init(title);
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
}
|
|
|
|
|
2007-10-25 03:09:59 +04:00
|
|
|
bx_list_c::bx_list_c(bx_param_c *parent, const char *name, const char *title, bx_param_c **init_list)
|
2006-03-08 21:10:41 +03:00
|
|
|
: bx_param_c(SIM->gen_param_id(), name, "")
|
2001-06-18 18:11:55 +04:00
|
|
|
{
|
2006-02-18 19:53:18 +03:00
|
|
|
set_type(BXT_LIST);
|
2001-06-19 08:55:01 +04:00
|
|
|
this->size = 0;
|
|
|
|
while (init_list[this->size] != NULL)
|
|
|
|
this->size++;
|
|
|
|
this->maxsize = this->size;
|
2006-05-30 02:33:38 +04:00
|
|
|
this->list = new bx_param_c* [maxsize];
|
2001-06-19 08:55:01 +04:00
|
|
|
for (int i=0; i<this->size; i++)
|
2001-06-18 18:11:55 +04:00
|
|
|
this->list[i] = init_list[i];
|
2006-02-17 00:44:17 +03:00
|
|
|
this->parent = NULL;
|
2006-03-05 13:24:29 +03:00
|
|
|
if (parent) {
|
|
|
|
BX_ASSERT(parent->get_type() == BXT_LIST);
|
|
|
|
this->parent = (bx_list_c *)parent;
|
|
|
|
this->parent->add(this);
|
|
|
|
}
|
|
|
|
init(title);
|
2001-06-18 18:11:55 +04:00
|
|
|
}
|
|
|
|
|
2001-12-21 22:33:18 +03:00
|
|
|
bx_list_c::~bx_list_c()
|
|
|
|
{
|
2006-09-19 00:31:37 +04:00
|
|
|
if (list != NULL) {
|
|
|
|
for (int i=0; i<this->size; i++) {
|
|
|
|
delete list[i];
|
|
|
|
}
|
2006-09-19 01:24:27 +04:00
|
|
|
delete [] list;
|
2006-09-19 00:31:37 +04:00
|
|
|
}
|
2006-05-30 21:01:27 +04:00
|
|
|
if (title != NULL) delete title;
|
|
|
|
if (choice != NULL) delete choice;
|
2001-12-21 22:33:18 +03:00
|
|
|
}
|
|
|
|
|
2006-02-26 22:11:20 +03:00
|
|
|
void bx_list_c::init(const char *list_title)
|
2001-06-18 18:11:55 +04:00
|
|
|
{
|
2001-06-21 18:37:55 +04:00
|
|
|
// the title defaults to the name
|
2006-03-06 21:50:55 +03:00
|
|
|
this->title = new bx_param_string_c(NULL,
|
|
|
|
"list_title",
|
|
|
|
"", "",
|
2006-02-18 19:53:18 +03:00
|
|
|
get_name(), 80);
|
|
|
|
if ((list_title != NULL) && (strlen(list_title) > 0)) {
|
2006-02-28 17:02:06 +03:00
|
|
|
this->title->set((char *)list_title);
|
2006-02-18 19:53:18 +03:00
|
|
|
}
|
2009-03-16 00:16:17 +03:00
|
|
|
this->options = 0;
|
2006-03-06 21:50:55 +03:00
|
|
|
this->choice = new bx_param_num_c(NULL,
|
2006-05-28 01:37:36 +04:00
|
|
|
"list_choice", "", "", 0, BX_MAX_BIT64S, 1);
|
2001-06-18 18:11:55 +04:00
|
|
|
}
|
|
|
|
|
2006-05-30 02:33:38 +04:00
|
|
|
void bx_list_c::set_parent(bx_param_c *newparent)
|
|
|
|
{
|
2006-03-07 23:32:07 +03:00
|
|
|
if (parent) {
|
|
|
|
// if this object already had a parent, the correct thing
|
|
|
|
// to do would be to remove this object from the parent's
|
|
|
|
// list of children. Deleting children is currently
|
|
|
|
// not supported.
|
|
|
|
BX_PANIC(("bx_list_c::set_parent: changing from one parent to another is not supported"));
|
|
|
|
}
|
|
|
|
if (newparent) {
|
|
|
|
BX_ASSERT(newparent->get_type() == BXT_LIST);
|
|
|
|
this->parent = (bx_list_c *)newparent;
|
|
|
|
this->parent->add(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-26 22:11:20 +03:00
|
|
|
bx_list_c* bx_list_c::clone()
|
2002-09-23 00:56:12 +04:00
|
|
|
{
|
2006-02-28 17:02:06 +03:00
|
|
|
bx_list_c *newlist = new bx_list_c(NULL, name, title->getptr(), maxsize);
|
2006-02-26 22:11:20 +03:00
|
|
|
for (int i=0; i<get_size(); i++)
|
|
|
|
newlist->add(get(i));
|
2009-03-16 00:16:17 +03:00
|
|
|
newlist->set_options(options);
|
2002-09-23 00:56:12 +04:00
|
|
|
return newlist;
|
|
|
|
}
|
|
|
|
|
2006-02-26 22:11:20 +03:00
|
|
|
void bx_list_c::add(bx_param_c *param)
|
2001-06-18 18:11:55 +04:00
|
|
|
{
|
2009-02-02 16:03:28 +03:00
|
|
|
if (size >= maxsize) {
|
2006-02-26 22:11:20 +03:00
|
|
|
BX_PANIC(("add param '%s' to bx_list_c '%s': list capacity exceeded",
|
|
|
|
param->get_name(), get_name()));
|
2009-02-02 16:03:28 +03:00
|
|
|
return;
|
|
|
|
}
|
2001-06-18 18:11:55 +04:00
|
|
|
list[size] = param;
|
|
|
|
size++;
|
|
|
|
}
|
|
|
|
|
2006-02-26 22:11:20 +03:00
|
|
|
bx_param_c* bx_list_c::get(int index)
|
2001-06-18 18:11:55 +04:00
|
|
|
{
|
2006-02-26 22:11:20 +03:00
|
|
|
BX_ASSERT(index >= 0 && index < size);
|
2001-06-18 18:11:55 +04:00
|
|
|
return list[index];
|
|
|
|
}
|
|
|
|
|
2006-02-26 22:11:20 +03:00
|
|
|
bx_param_c* bx_list_c::get_by_name(const char *name)
|
2006-02-17 00:44:17 +03:00
|
|
|
{
|
2008-09-20 01:31:08 +04:00
|
|
|
int imax = get_size();
|
|
|
|
for (int i=0; i<imax; i++) {
|
2006-02-17 00:44:17 +03:00
|
|
|
bx_param_c *p = get(i);
|
2009-02-02 16:03:28 +03:00
|
|
|
if (!stricmp(name, p->get_name())) {
|
2006-02-17 00:44:17 +03:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-02-26 22:11:20 +03:00
|
|
|
void bx_list_c::reset()
|
2006-02-17 00:44:17 +03:00
|
|
|
{
|
2008-09-20 01:31:08 +04:00
|
|
|
int imax = get_size();
|
|
|
|
for (int i=0; i<imax; i++) {
|
2006-02-17 00:44:17 +03:00
|
|
|
get(i)->reset();
|
|
|
|
}
|
|
|
|
}
|
2006-09-07 22:50:51 +04:00
|
|
|
|
|
|
|
void bx_list_c::clear()
|
|
|
|
{
|
2008-09-20 01:31:08 +04:00
|
|
|
int imax = get_size();
|
|
|
|
for (int i=0; i<imax; i++) {
|
|
|
|
bx_param_c *param = get(i);
|
2009-03-06 19:07:56 +03:00
|
|
|
if (param->get_parent() == this) {
|
|
|
|
delete param;
|
|
|
|
}
|
2006-09-07 22:50:51 +04:00
|
|
|
}
|
2008-09-20 01:31:08 +04:00
|
|
|
size = 0;
|
2006-09-07 22:50:51 +04:00
|
|
|
}
|
2009-01-05 00:46:20 +03:00
|
|
|
|
|
|
|
void bx_list_c::remove(const char *name)
|
|
|
|
{
|
|
|
|
int imax = get_size();
|
|
|
|
int found = 0;
|
|
|
|
for (int i=0; i<imax; i++) {
|
|
|
|
bx_param_c *p = get(i);
|
2009-02-02 16:03:28 +03:00
|
|
|
if (!found && !stricmp(name, p->get_name())) {
|
2009-03-06 19:07:56 +03:00
|
|
|
if (p->get_parent() == this) {
|
|
|
|
delete p;
|
|
|
|
}
|
2009-01-05 00:46:20 +03:00
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
if (found) {
|
|
|
|
list[i] = list[i+1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (found) {
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
}
|