Bochs/bochs/gui/siminterface.cc

1579 lines
46 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////
// $Id$
/////////////////////////////////////////////////////////////////////////
//
2020-08-06 23:21:14 +03:00
// Copyright (C) 2002-2020 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
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
/////////////////////////////////////////////////////////////////////////
2009-12-04 23:02:12 +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
// 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.
#include "param_names.h"
#include "iodev.h"
#include "virt_timer.h"
bx_simulator_interface_c *SIM = NULL;
logfunctions *siminterface_log = NULL;
bx_list_c *root_param = NULL;
#define LOG_THIS siminterface_log->
// 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
// not need to include bochs.h.
//
// 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
//
static int rt_conf_id = 0;
typedef struct _rt_conf_entry_t {
int id;
void *device;
rt_conf_handler_t handler;
struct _rt_conf_entry_t *next;
} rt_conf_entry_t;
typedef struct _addon_option_t {
const char *name;
addon_option_parser_t parser;
addon_option_save_t savefn;
struct _addon_option_t *next;
} addon_option_t;
class bx_real_sim_c : public bx_simulator_interface_c {
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
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;
rt_conf_entry_t *rt_conf_entries;
addon_option_t *addon_options;
int init_done;
int enabled;
// save context to jump to if we must quit unexpectedly
jmp_buf *quit_context;
int exit_code;
unsigned param_id;
bx_bool bx_debug_gui;
bx_bool bx_log_viewer;
bx_bool wxsel;
public:
bx_real_sim_c();
virtual ~bx_real_sim_c() {}
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;}
virtual void reset_all_param();
// new param methods
virtual bx_param_c *get_param(const char *pname, bx_param_c *base=NULL);
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);
virtual Bit32u gen_param_id() { return param_id++; }
virtual int get_n_log_modules();
virtual const char *get_logfn_name(int mod);
virtual int get_logfn_id(const char *name);
virtual const 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 const char *get_action_name(int action);
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h --- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200 +++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100 @@ -2,7 +2,7 @@ // $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2015 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -276,8 +276,9 @@ void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); - void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status); - void ask (int level, const char *prefix, const char *fmt, va_list ap); + void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status); + void warn(int level, const char *prefix, const char *fmt, va_list ap); + void ask(int level, const char *prefix, const char *fmt, va_list ap); void put(const char *p); void put(const char *n, const char *p); void setio(class iofunctions *); @@ -334,7 +335,8 @@ void set_log_action(int loglevel, int action); const char *getlevel(int i) const; const char *getaction(int i) const; - + int isaction(const char *val) const; + protected: int n_logfn; #define MAX_LOGFNS 512 diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES --- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100 +++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100 @@ -1,5 +1,8 @@ Changes after 2.6.8 release: +- General + - Added new log action "warn", designed to show a message box on error events. + - Configure and compile - Added Android host platform support. diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc --- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200 +++ ./config.cc 2016-12-27 19:53:10.461420368 +0100 @@ -2062,15 +2062,8 @@ actstr = strtok(NULL, ""); if (actstr != NULL) { def_action = !strcmp(module, "action"); - if (!strcmp(actstr, "fatal")) - action = ACT_FATAL; - else if (!strcmp (actstr, "report")) - action = ACT_REPORT; - else if (!strcmp (actstr, "ignore")) - action = ACT_IGNORE; - else if (!strcmp (actstr, "ask")) - action = ACT_ASK; - else { + action = SIM->is_action_name(actstr); + if (action < ACT_IGNORE) { PARSE_ERR(("%s: %s directive malformed.", context, params[0])); free(param); return -1; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc --- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200 +++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100 @@ -2,7 +2,7 @@ // $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2014-2015 The Bochs Project +// Copyright (C) 2014-2016 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 @@ -1478,20 +1478,16 @@ SDL_MessageBoxData msgboxdata; SDL_MessageBoxButtonData buttondata[4]; int level, retcode; -#if BX_DEBUGGER || BX_GDBSTUB - int defbtn = 3; -#else - int defbtn = 2; -#endif char message[512]; level = event->u.logmsg.level; - sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg); + sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); msgboxdata.flags = SDL_MESSAGEBOX_ERROR; msgboxdata.window = window; msgboxdata.title = SIM->get_log_level_name(level); msgboxdata.message = message; - msgboxdata.numbuttons = defbtn + 1; + msgboxdata.numbuttons = 2; msgboxdata.buttons = buttondata; msgboxdata.colorScheme = NULL; buttondata[0].flags = 0; @@ -1500,14 +1496,18 @@ buttondata[1].flags = 0; buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS; buttondata[1].text = "Alwayscont"; + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + msgboxdata.numbuttons = 3; + buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; + buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE; + buttondata[2].text = "Quit"; #if BX_DEBUGGER || BX_GDBSTUB - buttondata[2].flags = 0; - buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; - buttondata[2].text = "Debugger"; -#endif - buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; - buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE; - buttondata[defbtn].text = "Quit"; + msgboxdata.numbuttons = 4; + buttondata[3].flags = 0; + buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; + buttondata[3].text = "Debugger"; +#endif + } if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) { return -1; } else { diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc --- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100 +++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100 @@ -2,7 +2,7 @@ // $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2015 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -100,6 +100,7 @@ virtual int get_log_action(int mod, int level); virtual void set_log_action(int mod, int level, int action); virtual const char *get_action_name(int action); + virtual int is_action_name(const char *val); virtual int get_default_log_action(int level) { return logfunctions::get_default_action(level); } @@ -123,6 +124,7 @@ 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_warn(const char *prefix, int level, const char *msg); virtual int log_ask(const char *prefix, int level, const char *msg); virtual void log_msg(const char *prefix, int level, const char *msg); virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; } @@ -420,6 +422,11 @@ return io->getaction(action); } +int bx_real_sim_c::is_action_name(const char *val) +{ + return io->isaction(val); +} + const char *bx_real_sim_c::get_log_level_name(int level) { return io->getlevel(level); @@ -575,6 +582,21 @@ } } +int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg) +{ + BxEvent be; + be.type = BX_SYNC_EVT_LOG_ASK; + be.u.logmsg.prefix = prefix; + be.u.logmsg.level = level; + be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN; + // default return value in case something goes wrong. + be.retcode = BX_LOG_NOTIFY_FAILED; + // calling notify + sim_to_ci_event(&be); + return be.retcode; +} + // returns 0 for continue, 1 for alwayscontinue, 2 for die. int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg) { @@ -583,6 +605,7 @@ be.u.logmsg.prefix = prefix; be.u.logmsg.level = level; be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_ASKDLG; // default return value in case something goes wrong. be.retcode = BX_LOG_NOTIFY_FAILED; // calling notify @@ -1157,16 +1180,10 @@ } else if (!strncmp(string, "PANIC=", 6)) { type = LOGLEV_PANIC; } - 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; + action = is_action_name(string+j); + if (action >= ACT_IGNORE) { + set_log_action(dev, type, action); } - set_log_action(dev, type, action); } else { if (i == 1) { BX_ERROR(("restore_logopts(): log module '%s' not found", devname)); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h --- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200 +++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100 @@ -168,6 +168,7 @@ typedef enum { ACT_IGNORE = 0, ACT_REPORT, + ACT_WARN, ACT_ASK, ACT_FATAL, N_ACT @@ -178,11 +179,11 @@ // normally all action choices are available for all event types. The exclude // expression allows some choices to be eliminated if they don't make any // sense. For example, it would be stupid to ignore a panic. -#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ - /* can't die or ask, on debug or info events */ \ - (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \ - /* can't ignore panics */ \ - || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ +#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ + /* can't die, ask or warn, on debug or info events */ \ + (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \ + /* can't ignore panics */ \ + || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ ) // floppy / cdrom media status @@ -392,6 +393,7 @@ // synchronizing threads, etc. for each. typedef struct { Bit8u level; + Bit8u flag; const char *prefix; const char *msg; } BxLogMsgEvent; @@ -419,6 +421,12 @@ BX_LOG_NOTIFY_FAILED }; +enum { + BX_LOG_ASK_ASKDLG, + BX_LOG_ASK_MSGBOX_WARN, + BX_LOG_ASK_MSGBOX_QUIT +}; + // Event type: BX_SYNC_EVT_GET_DBG_COMMAND // // This is a synchronous event sent from the simulator to the debugger @@ -675,6 +683,7 @@ virtual int get_default_log_action(int level) {return -1;} virtual void set_default_log_action(int level, int action) {} virtual const char *get_action_name(int action) {return NULL;} + virtual int is_action_name(const char *val) {return -1;} virtual const char *get_log_level_name(int level) {return NULL;} virtual int get_max_log_level() {return -1;} @@ -715,6 +724,9 @@ // send an event from the simulator to the CI. virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;} + // called from simulator when it hits errors, to warn the user + // before continuing simulation + virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;} // called from simulator when it hits serious errors, to ask if the user // wants to continue or not virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;} diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc --- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100 +++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100 @@ -2,7 +2,7 @@ // $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2013 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -552,8 +552,8 @@ } static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] "; -static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" }; -static int log_level_n_choices_normal = 4; +static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" }; +static int log_level_n_choices_normal = N_ACT; void bx_log_options(int individual) { @@ -589,7 +589,7 @@ bx_print_log_action_table(); for (int level=0; level<SIM->get_max_log_level(); level++) { char prompt[1024]; - int action, default_action = 4; // default to no change + int action, default_action = N_ACT; // default to no change sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level)); // do show the no change choice (choices=4) if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0) @@ -718,47 +718,50 @@ event->retcode = event->u.param.param->text_ask(stdin, stderr); return event; case BX_SYNC_EVT_LOG_ASK: - { - int level = event->u.logmsg.level; - fprintf(stderr, "========================================================================\n"); - fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); - fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); - fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); - fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); - fprintf(stderr, " cont - continue execution\n"); - fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); - fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); - fprintf(stderr, " die - stop execution now\n"); - fprintf(stderr, " abort - dump core %s\n", - BX_HAVE_ABORT ? "" : "(Disabled)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + int level = event->u.logmsg.level; + fprintf(stderr, "========================================================================\n"); + fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); + fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); + fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); + fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); + fprintf(stderr, " cont - continue execution\n"); + fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); + fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); + fprintf(stderr, " die - stop execution now\n"); + fprintf(stderr, " abort - dump core %s\n", + BX_HAVE_ABORT ? "" : "(Disabled)"); #if BX_DEBUGGER - fprintf(stderr, " debug - continue and return to bochs debugger\n"); + fprintf(stderr, " debug - continue and return to bochs debugger\n"); #endif #if BX_GDBSTUB - fprintf(stderr, " debug - hand control to gdb\n"); + fprintf(stderr, " debug - hand control to gdb\n"); #endif - int choice; + int choice; ask: - if (ask_menu("Choose one of the actions above: [%s] ", "", - log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) - event->retcode = -1; - // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. - if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; - fflush(stdout); - fflush(stderr); - event->retcode = choice; - } - return event; - case BX_ASYNC_EVT_REFRESH: - case BX_ASYNC_EVT_DBG_MSG: - case BX_ASYNC_EVT_LOG_MSG: - // The text mode interface does not use these events, so just ignore - // them. - return event; - default: - fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); - return event; + if (ask_menu("Choose one of the actions above: [%s] ", "", + log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) + event->retcode = -1; + // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. + if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; + fflush(stdout); + fflush(stderr); + event->retcode = choice; + } else { + // warning prompt not implemented + event->retcode = 0; + } + return event; + case BX_ASYNC_EVT_REFRESH: + case BX_ASYNC_EVT_DBG_MSG: + case BX_ASYNC_EVT_LOG_MSG: + // The text mode interface does not use these events, so just ignore + // them. + return event; + default: + fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); + return event; } assert(0); // switch statement should return } diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc --- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200 +++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100 @@ -2,7 +2,7 @@ // $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2003-2014 The Bochs Project +// Copyright (C) 2003-2016 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 @@ -27,7 +27,7 @@ #include "win32res.h" #include "win32paramdlg.h" -const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"}; +const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"}; HWND GetBochsWindow() { @@ -97,12 +97,16 @@ SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue"); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); #if BX_DEBUGGER - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); #endif - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + } else { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0); + } SetFocus(GetDlgItem(hDlg, IDASKLIST)); return FALSE; case WM_CLOSE: diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc --- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100 +++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -208,7 +208,6 @@ : wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3}; static wxString names[] = ADVLOG_OPTS_TYPE_NAMES; SetTitle(ADVLOG_OPTS_TITLE); vertSizer = new wxBoxSizer(wxVERTICAL); @@ -1563,7 +1562,7 @@ bool includeNoChange) { static wxString choices[] = LOG_OPTS_CHOICES; - static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4}; + static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5}; wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize); int lastChoice = 0; // remember index of last choice int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h --- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100 +++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $ //////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -354,10 +354,10 @@ #define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?") #define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") } #define LOG_OPTS_N_TYPES 4 -#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") } -#define LOG_OPTS_N_CHOICES_NORMAL 4 -#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change" -#define LOG_OPTS_NO_CHANGE 4 // index of "no change" +#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") } +#define LOG_OPTS_N_CHOICES_NORMAL 5 +#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change" +#define LOG_OPTS_NO_CHANGE 5 // index of "no change" #define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".") wxFlexGridSizer *gridSizer; wxChoice *action[LOG_OPTS_N_TYPES]; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc --- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100 +++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100 @@ -2,7 +2,7 @@ // $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -1158,6 +1158,10 @@ #if !BX_DEBUGGER && !BX_GDBSTUB dlg.EnableButton(dlg.DEBUG, FALSE); #endif + if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) { + dlg.EnableButton(dlg.DIE, FALSE); + dlg.EnableButton(dlg.DUMP, FALSE); + } dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8)); dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8)); int n = dlg.ShowModal(); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc --- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100 +++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100 @@ -2687,11 +2687,7 @@ } else { size_x = 30 + maxlen * 6; } - if (lines < 3) { - size_y = 90; - } else { - size_y = 60 + lines * 15; - } + size_y = 70 + lines * 15; x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y, (mode == XDLG_SIMPLE) ? 1 : 2); ypos = 34; @@ -2729,11 +2725,21 @@ bx_param_string_c *sparam; bx_param_enum_c *eparam; bx_list_c *list; + char message[256]; switch (event->type) { case BX_SYNC_EVT_LOG_ASK: - event->retcode = x11_ask_dialog(event); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + event->retcode = x11_ask_dialog(event); + } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) { + const char *title = SIM->get_log_level_name(event->u.logmsg.level); + sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); + bx_param_bool_c bparam(NULL, "warn", title, message, 1); + x11_message_box(&bparam, XDLG_SIMPLE); + event->retcode = 0; + } return event; case BX_SYNC_EVT_ASK_PARAM: param = event->u.param.param; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc --- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200 +++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100 @@ -2,7 +2,7 @@ // $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2014 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -50,11 +50,25 @@ else return "?"; } +static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" }; + const char* iofunctions::getaction(int i) const { - static const char *name[] = { "ignore", "report", "ask", "fatal" }; assert (i>=ACT_IGNORE && i<N_ACT); - return name[i]; + return act_name[i]; +} + +int iofunctions::isaction(const char *val) const +{ + int action = -1; + + for (int i = 0; i < N_ACT; i++) { + if (!strcmp(val, act_name[i])) { + action = ACT_IGNORE + i; + break; + } + } + return action; } void iofunctions::flush(void) @@ -414,6 +428,11 @@ logio->out(LOGLEV_ERROR, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_ERROR] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_ERROR, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_ERROR] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_ERROR, prefix, fmt, ap); @@ -438,6 +457,11 @@ logio->out(LOGLEV_PANIC, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_PANIC] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_PANIC, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_PANIC] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_PANIC, prefix, fmt, ap); @@ -465,6 +489,36 @@ // the actions ask() and fatal() are not supported here } +void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap) +{ + // Guard against reentry on warn() function. The danger is that some + // function that's called within warn() could trigger another + // BX_ERROR that could call warn() again, leading to infinite + // recursion and infinite asks. + static char in_warn_already = 0; + char buf1[1024]; + if (in_warn_already) { + fprintf(stderr, "logfunctions::warn() should not reenter!!\n"); + return; + } + in_warn_already = 1; + vsnprintf(buf1, sizeof(buf1), fmt, ap); + // FIXME: facility set to 0 because it's unknown. + + // update vga screen. This is useful because sometimes useful messages + // are printed on the screen just before a panic. It's also potentially + // dangerous if this function calls ask again... That's why I added + // the reentry check above. + SIM->refresh_vga(); + + // ensure the text screen is showing + SIM->set_display_mode(DISP_MODE_CONFIG); + SIM->log_warn(prefix, level, buf1); + // return to simulation mode + SIM->set_display_mode(DISP_MODE_SIM); + in_warn_already = 0; +} + void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap) { // Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
virtual int is_action_name(const char *val);
virtual int get_default_log_action(int level) {
return logfunctions::get_default_action(level);
}
virtual void set_default_log_action(int level, int action) {
logfunctions::set_default_action(level, action);
}
virtual const char *get_log_level_name(int level);
virtual int get_max_log_level() { return N_LOGLEV; }
virtual void quit_sim(int code);
virtual int get_exit_code() { return exit_code; }
virtual int get_default_rc(char *path, int len);
virtual int read_rc(const char *path);
virtual int write_rc(const char *path, int overwrite);
virtual int get_log_file(char *path, int len);
2009-11-08 23:47:03 +03:00
virtual int set_log_file(const char *path);
virtual int get_log_prefix(char *prefix, int len);
2009-11-08 23:47:03 +03:00
virtual int set_log_prefix(const char *prefix);
virtual int get_debugger_log_file(char *path, int len);
2009-11-08 23:47:03 +03:00
virtual int set_debugger_log_file(const char *path);
virtual int hdimage_get_mode(const char *mode);
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_dlg(const char *prefix, int level, const char *msg, int mode);
virtual void log_msg(const char *prefix, int level, const char *msg);
virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; }
virtual bx_bool has_log_viewer() const { return bx_log_viewer; }
virtual int ask_param(bx_param_c *param);
virtual int ask_param(const char *pname);
// 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);
// 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);
// simple message box
virtual void message_box(const char *title, const char *message);
// called at a regular interval, currently by the keyboard handler.
virtual void periodic();
virtual int create_disk_image(const char *filename, int sectors, bx_bool overwrite);
virtual void refresh_ci();
virtual void refresh_vga() {
if (init_done) {
DEV_vga_refresh(0);
}
}
virtual void handle_events() {
// maybe need to check if something has been initialized yet?
bx_gui->handle_events();
}
// find first hard drive or cdrom
bx_param_c *get_first_atadevice(Bit32u search_type);
bx_param_c *get_first_cdrom() {
return get_first_atadevice(BX_ATA_DEVICE_CDROM);
}
bx_param_c *get_first_hd() {
return get_first_atadevice(BX_ATA_DEVICE_DISK);
}
virtual bx_bool is_pci_device(const char *name);
virtual bx_bool is_agp_device(const char *name);
- 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
virtual void debug_break();
virtual void debug_interpret_cmd(char *cmd);
virtual char *debug_get_next_command();
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
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
virtual void register_configuration_interface (
const char* name,
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
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);
virtual int begin_simulation(int argc, char *argv[]);
virtual int register_runtime_config_handler(void *dev, rt_conf_handler_t handler);
virtual void unregister_runtime_config_handler(int id);
virtual void update_runtime_options();
virtual void set_sim_thread_func(is_sim_thread_func_t func) {}
virtual bx_bool is_sim_thread();
virtual void set_debug_gui(bx_bool val) { bx_debug_gui = val; }
virtual bx_bool has_debug_gui() const { return bx_debug_gui; }
virtual bx_bool is_wx_selected() const { return wxsel; }
// provide interface to bx_gui->set_display_mode() method for config
// interfaces to use.
virtual void set_display_mode(disp_mode_t newmode) {
if (bx_gui != NULL)
bx_gui->set_display_mode(newmode);
}
virtual bx_bool test_for_text_console();
// add-on config option support
virtual bx_bool register_addon_option(const char *keyword, addon_option_parser_t parser, addon_option_save_t save_func);
virtual bx_bool unregister_addon_option(const char *keyword);
virtual bx_bool is_addon_option(const char *keyword);
virtual Bit32s parse_addon_option(const char *context, int num_params, char *params []);
virtual Bit32s save_addon_options(FILE *fp);
// statistics
virtual void init_statistics();
virtual void cleanup_statistics();
virtual bx_list_c *get_statistics_root() {
return (bx_list_c*)get_param("statistics", NULL);
}
// save/restore support
virtual void init_save_restore();
virtual void cleanup_save_restore();
virtual bx_bool save_state(const char *checkpoint_path);
virtual bx_bool restore_config();
virtual bx_bool restore_logopts();
virtual bx_bool restore_hardware();
virtual bx_list_c *get_bochs_root() {
return (bx_list_c*)get_param("bochs", NULL);
}
virtual bx_bool restore_bochs_param(bx_list_c *root, const char *sr_path, const char *restore_name);
// special config parameter and options functions for plugins
virtual bx_bool opt_plugin_ctrl(const char *plugname, bx_bool load);
virtual void init_std_nic_options(const char *name, bx_list_c *menu);
virtual void init_usb_options(const char *usb_name, const char *pname, int maxports);
virtual int parse_param_from_list(const char *context, const char *param, bx_list_c *base);
virtual int parse_nic_params(const char *context, const char *param, bx_list_c *base);
virtual int parse_usb_port_params(const char *context, bx_bool devopt,
const char *param, int maxports, bx_list_c *base);
virtual int split_option_list(const char *msg, const char *rawopt, char **argv, int max_argv);
virtual int write_param_list(FILE *fp, bx_list_c *base, const char *optname, bx_bool multiline);
virtual int write_usb_options(FILE *fp, int maxports, bx_list_c *base);
#if BX_USE_GUI_CONSOLE
virtual int bx_printf(const char *fmt, ...);
virtual char* bx_gets(char *s, int size, FILE *stream);
#endif
private:
bx_bool save_sr_param(FILE *fp, bx_param_c *node, const char *sr_path, int level);
};
// recursive function to find parameters from the path
static bx_param_c *find_param(const char *full_pname, const char *rest_of_pname, bx_param_c *base)
{
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));
// 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!"));
}
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;
bx_param_c *child = list->get_by_name(component);
// 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
return find_param(full_pname, from, child);
}
bx_param_c *bx_real_sim_c::get_param(const char *pname, bx_param_c *base)
{
if (base == NULL)
base = root_param;
// to access top level object, look for parameter "."
if (pname[0] == '.' && pname[1] == 0)
return base;
return find_param(pname, pname, base);
}
bx_param_num_c *bx_real_sim_c::get_param_num(const char *pname, bx_param_c *base)
{
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));
return NULL;
}
int type = gen->get_type();
if (type == BXT_PARAM_NUM || type == BXT_PARAM_BOOL || type == BXT_PARAM_ENUM)
return (bx_param_num_c *)gen;
BX_ERROR(("get_param_num(%s) could not find a number parameter with that name", pname));
return NULL;
}
bx_param_string_c *bx_real_sim_c::get_param_string(const char *pname, bx_param_c *base)
{
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));
return NULL;
}
if (gen->get_type() == BXT_PARAM_STRING || gen->get_type() == BXT_PARAM_BYTESTRING)
return (bx_param_string_c *)gen;
BX_ERROR(("get_param_string(%s) could not find a string parameter with that name", pname));
return NULL;
}
bx_param_bool_c *bx_real_sim_c::get_param_bool(const char *pname, bx_param_c *base)
{
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));
return NULL;
}
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));
return NULL;
}
bx_param_enum_c *bx_real_sim_c::get_param_enum(const char *pname, bx_param_c *base)
{
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));
return NULL;
}
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));
return NULL;
}
void bx_init_siminterface()
{
if (SIM == NULL) {
siminterface_log = new logfunctions();
siminterface_log->put("siminterface", "SIM");
SIM = new bx_real_sim_c();
}
if (root_param == NULL) {
root_param = new bx_list_c(NULL,
"bochs",
"list of top level bochs parameters"
);
}
}
bx_real_sim_c::bx_real_sim_c()
{
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
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;
bx_debug_gui = 0;
bx_log_viewer = 0;
wxsel = 0;
enabled = 1;
init_done = 0;
quit_context = NULL;
exit_code = 0;
param_id = BXP_NEW_PARAM_ID;
rt_conf_entries = NULL;
addon_options = NULL;
}
void bx_real_sim_c::reset_all_param()
{
bx_reset_options();
}
int bx_real_sim_c::get_n_log_modules()
{
return io->get_n_logfns();
}
const char *bx_real_sim_c::get_logfn_name(int mod)
{
logfunc_t *logfn = io->get_logfn(mod);
return logfn->get_name();
}
int bx_real_sim_c::get_logfn_id(const char *name)
{
logfunc_t *logfn;
int id = -1;
for (int i = 0; i < io->get_n_logfns(); i++) {
logfn = io->get_logfn(i);
if (!stricmp(name, logfn->get_name())) {
id = i;
break;
}
}
return id;
}
const char *bx_real_sim_c::get_prefix(int mod)
{
logfunc_t *logfn = io->get_logfn(mod);
return logfn->getprefix();
}
int bx_real_sim_c::get_log_action(int mod, int level)
{
logfunc_t *logfn = io->get_logfn(mod);
return logfn->getonoff(level);
}
void bx_real_sim_c::set_log_action(int mod, int level, int action)
{
// normal
if (mod >= 0) {
logfunc_t *logfn = io->get_logfn(mod);
logfn->setonoff(level, action);
return;
}
// if called with mod<0 loop over all
int nmod = get_n_log_modules();
for (mod=0; mod<nmod; mod++)
set_log_action(mod, level, action);
}
const char *bx_real_sim_c::get_action_name(int action)
{
return io->getaction(action);
}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h --- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200 +++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100 @@ -2,7 +2,7 @@ // $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2015 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -276,8 +276,9 @@ void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); - void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status); - void ask (int level, const char *prefix, const char *fmt, va_list ap); + void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status); + void warn(int level, const char *prefix, const char *fmt, va_list ap); + void ask(int level, const char *prefix, const char *fmt, va_list ap); void put(const char *p); void put(const char *n, const char *p); void setio(class iofunctions *); @@ -334,7 +335,8 @@ void set_log_action(int loglevel, int action); const char *getlevel(int i) const; const char *getaction(int i) const; - + int isaction(const char *val) const; + protected: int n_logfn; #define MAX_LOGFNS 512 diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES --- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100 +++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100 @@ -1,5 +1,8 @@ Changes after 2.6.8 release: +- General + - Added new log action "warn", designed to show a message box on error events. + - Configure and compile - Added Android host platform support. diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc --- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200 +++ ./config.cc 2016-12-27 19:53:10.461420368 +0100 @@ -2062,15 +2062,8 @@ actstr = strtok(NULL, ""); if (actstr != NULL) { def_action = !strcmp(module, "action"); - if (!strcmp(actstr, "fatal")) - action = ACT_FATAL; - else if (!strcmp (actstr, "report")) - action = ACT_REPORT; - else if (!strcmp (actstr, "ignore")) - action = ACT_IGNORE; - else if (!strcmp (actstr, "ask")) - action = ACT_ASK; - else { + action = SIM->is_action_name(actstr); + if (action < ACT_IGNORE) { PARSE_ERR(("%s: %s directive malformed.", context, params[0])); free(param); return -1; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc --- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200 +++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100 @@ -2,7 +2,7 @@ // $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2014-2015 The Bochs Project +// Copyright (C) 2014-2016 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 @@ -1478,20 +1478,16 @@ SDL_MessageBoxData msgboxdata; SDL_MessageBoxButtonData buttondata[4]; int level, retcode; -#if BX_DEBUGGER || BX_GDBSTUB - int defbtn = 3; -#else - int defbtn = 2; -#endif char message[512]; level = event->u.logmsg.level; - sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg); + sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); msgboxdata.flags = SDL_MESSAGEBOX_ERROR; msgboxdata.window = window; msgboxdata.title = SIM->get_log_level_name(level); msgboxdata.message = message; - msgboxdata.numbuttons = defbtn + 1; + msgboxdata.numbuttons = 2; msgboxdata.buttons = buttondata; msgboxdata.colorScheme = NULL; buttondata[0].flags = 0; @@ -1500,14 +1496,18 @@ buttondata[1].flags = 0; buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS; buttondata[1].text = "Alwayscont"; + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + msgboxdata.numbuttons = 3; + buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; + buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE; + buttondata[2].text = "Quit"; #if BX_DEBUGGER || BX_GDBSTUB - buttondata[2].flags = 0; - buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; - buttondata[2].text = "Debugger"; -#endif - buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; - buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE; - buttondata[defbtn].text = "Quit"; + msgboxdata.numbuttons = 4; + buttondata[3].flags = 0; + buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; + buttondata[3].text = "Debugger"; +#endif + } if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) { return -1; } else { diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc --- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100 +++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100 @@ -2,7 +2,7 @@ // $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2015 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -100,6 +100,7 @@ virtual int get_log_action(int mod, int level); virtual void set_log_action(int mod, int level, int action); virtual const char *get_action_name(int action); + virtual int is_action_name(const char *val); virtual int get_default_log_action(int level) { return logfunctions::get_default_action(level); } @@ -123,6 +124,7 @@ 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_warn(const char *prefix, int level, const char *msg); virtual int log_ask(const char *prefix, int level, const char *msg); virtual void log_msg(const char *prefix, int level, const char *msg); virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; } @@ -420,6 +422,11 @@ return io->getaction(action); } +int bx_real_sim_c::is_action_name(const char *val) +{ + return io->isaction(val); +} + const char *bx_real_sim_c::get_log_level_name(int level) { return io->getlevel(level); @@ -575,6 +582,21 @@ } } +int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg) +{ + BxEvent be; + be.type = BX_SYNC_EVT_LOG_ASK; + be.u.logmsg.prefix = prefix; + be.u.logmsg.level = level; + be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN; + // default return value in case something goes wrong. + be.retcode = BX_LOG_NOTIFY_FAILED; + // calling notify + sim_to_ci_event(&be); + return be.retcode; +} + // returns 0 for continue, 1 for alwayscontinue, 2 for die. int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg) { @@ -583,6 +605,7 @@ be.u.logmsg.prefix = prefix; be.u.logmsg.level = level; be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_ASKDLG; // default return value in case something goes wrong. be.retcode = BX_LOG_NOTIFY_FAILED; // calling notify @@ -1157,16 +1180,10 @@ } else if (!strncmp(string, "PANIC=", 6)) { type = LOGLEV_PANIC; } - 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; + action = is_action_name(string+j); + if (action >= ACT_IGNORE) { + set_log_action(dev, type, action); } - set_log_action(dev, type, action); } else { if (i == 1) { BX_ERROR(("restore_logopts(): log module '%s' not found", devname)); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h --- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200 +++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100 @@ -168,6 +168,7 @@ typedef enum { ACT_IGNORE = 0, ACT_REPORT, + ACT_WARN, ACT_ASK, ACT_FATAL, N_ACT @@ -178,11 +179,11 @@ // normally all action choices are available for all event types. The exclude // expression allows some choices to be eliminated if they don't make any // sense. For example, it would be stupid to ignore a panic. -#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ - /* can't die or ask, on debug or info events */ \ - (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \ - /* can't ignore panics */ \ - || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ +#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ + /* can't die, ask or warn, on debug or info events */ \ + (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \ + /* can't ignore panics */ \ + || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ ) // floppy / cdrom media status @@ -392,6 +393,7 @@ // synchronizing threads, etc. for each. typedef struct { Bit8u level; + Bit8u flag; const char *prefix; const char *msg; } BxLogMsgEvent; @@ -419,6 +421,12 @@ BX_LOG_NOTIFY_FAILED }; +enum { + BX_LOG_ASK_ASKDLG, + BX_LOG_ASK_MSGBOX_WARN, + BX_LOG_ASK_MSGBOX_QUIT +}; + // Event type: BX_SYNC_EVT_GET_DBG_COMMAND // // This is a synchronous event sent from the simulator to the debugger @@ -675,6 +683,7 @@ virtual int get_default_log_action(int level) {return -1;} virtual void set_default_log_action(int level, int action) {} virtual const char *get_action_name(int action) {return NULL;} + virtual int is_action_name(const char *val) {return -1;} virtual const char *get_log_level_name(int level) {return NULL;} virtual int get_max_log_level() {return -1;} @@ -715,6 +724,9 @@ // send an event from the simulator to the CI. virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;} + // called from simulator when it hits errors, to warn the user + // before continuing simulation + virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;} // called from simulator when it hits serious errors, to ask if the user // wants to continue or not virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;} diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc --- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100 +++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100 @@ -2,7 +2,7 @@ // $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2013 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -552,8 +552,8 @@ } static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] "; -static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" }; -static int log_level_n_choices_normal = 4; +static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" }; +static int log_level_n_choices_normal = N_ACT; void bx_log_options(int individual) { @@ -589,7 +589,7 @@ bx_print_log_action_table(); for (int level=0; level<SIM->get_max_log_level(); level++) { char prompt[1024]; - int action, default_action = 4; // default to no change + int action, default_action = N_ACT; // default to no change sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level)); // do show the no change choice (choices=4) if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0) @@ -718,47 +718,50 @@ event->retcode = event->u.param.param->text_ask(stdin, stderr); return event; case BX_SYNC_EVT_LOG_ASK: - { - int level = event->u.logmsg.level; - fprintf(stderr, "========================================================================\n"); - fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); - fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); - fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); - fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); - fprintf(stderr, " cont - continue execution\n"); - fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); - fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); - fprintf(stderr, " die - stop execution now\n"); - fprintf(stderr, " abort - dump core %s\n", - BX_HAVE_ABORT ? "" : "(Disabled)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + int level = event->u.logmsg.level; + fprintf(stderr, "========================================================================\n"); + fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); + fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); + fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); + fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); + fprintf(stderr, " cont - continue execution\n"); + fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); + fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); + fprintf(stderr, " die - stop execution now\n"); + fprintf(stderr, " abort - dump core %s\n", + BX_HAVE_ABORT ? "" : "(Disabled)"); #if BX_DEBUGGER - fprintf(stderr, " debug - continue and return to bochs debugger\n"); + fprintf(stderr, " debug - continue and return to bochs debugger\n"); #endif #if BX_GDBSTUB - fprintf(stderr, " debug - hand control to gdb\n"); + fprintf(stderr, " debug - hand control to gdb\n"); #endif - int choice; + int choice; ask: - if (ask_menu("Choose one of the actions above: [%s] ", "", - log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) - event->retcode = -1; - // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. - if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; - fflush(stdout); - fflush(stderr); - event->retcode = choice; - } - return event; - case BX_ASYNC_EVT_REFRESH: - case BX_ASYNC_EVT_DBG_MSG: - case BX_ASYNC_EVT_LOG_MSG: - // The text mode interface does not use these events, so just ignore - // them. - return event; - default: - fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); - return event; + if (ask_menu("Choose one of the actions above: [%s] ", "", + log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) + event->retcode = -1; + // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. + if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; + fflush(stdout); + fflush(stderr); + event->retcode = choice; + } else { + // warning prompt not implemented + event->retcode = 0; + } + return event; + case BX_ASYNC_EVT_REFRESH: + case BX_ASYNC_EVT_DBG_MSG: + case BX_ASYNC_EVT_LOG_MSG: + // The text mode interface does not use these events, so just ignore + // them. + return event; + default: + fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); + return event; } assert(0); // switch statement should return } diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc --- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200 +++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100 @@ -2,7 +2,7 @@ // $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2003-2014 The Bochs Project +// Copyright (C) 2003-2016 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 @@ -27,7 +27,7 @@ #include "win32res.h" #include "win32paramdlg.h" -const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"}; +const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"}; HWND GetBochsWindow() { @@ -97,12 +97,16 @@ SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue"); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); #if BX_DEBUGGER - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); #endif - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + } else { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0); + } SetFocus(GetDlgItem(hDlg, IDASKLIST)); return FALSE; case WM_CLOSE: diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc --- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100 +++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -208,7 +208,6 @@ : wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3}; static wxString names[] = ADVLOG_OPTS_TYPE_NAMES; SetTitle(ADVLOG_OPTS_TITLE); vertSizer = new wxBoxSizer(wxVERTICAL); @@ -1563,7 +1562,7 @@ bool includeNoChange) { static wxString choices[] = LOG_OPTS_CHOICES; - static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4}; + static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5}; wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize); int lastChoice = 0; // remember index of last choice int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h --- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100 +++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $ //////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -354,10 +354,10 @@ #define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?") #define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") } #define LOG_OPTS_N_TYPES 4 -#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") } -#define LOG_OPTS_N_CHOICES_NORMAL 4 -#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change" -#define LOG_OPTS_NO_CHANGE 4 // index of "no change" +#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") } +#define LOG_OPTS_N_CHOICES_NORMAL 5 +#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change" +#define LOG_OPTS_NO_CHANGE 5 // index of "no change" #define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".") wxFlexGridSizer *gridSizer; wxChoice *action[LOG_OPTS_N_TYPES]; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc --- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100 +++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100 @@ -2,7 +2,7 @@ // $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -1158,6 +1158,10 @@ #if !BX_DEBUGGER && !BX_GDBSTUB dlg.EnableButton(dlg.DEBUG, FALSE); #endif + if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) { + dlg.EnableButton(dlg.DIE, FALSE); + dlg.EnableButton(dlg.DUMP, FALSE); + } dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8)); dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8)); int n = dlg.ShowModal(); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc --- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100 +++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100 @@ -2687,11 +2687,7 @@ } else { size_x = 30 + maxlen * 6; } - if (lines < 3) { - size_y = 90; - } else { - size_y = 60 + lines * 15; - } + size_y = 70 + lines * 15; x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y, (mode == XDLG_SIMPLE) ? 1 : 2); ypos = 34; @@ -2729,11 +2725,21 @@ bx_param_string_c *sparam; bx_param_enum_c *eparam; bx_list_c *list; + char message[256]; switch (event->type) { case BX_SYNC_EVT_LOG_ASK: - event->retcode = x11_ask_dialog(event); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + event->retcode = x11_ask_dialog(event); + } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) { + const char *title = SIM->get_log_level_name(event->u.logmsg.level); + sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); + bx_param_bool_c bparam(NULL, "warn", title, message, 1); + x11_message_box(&bparam, XDLG_SIMPLE); + event->retcode = 0; + } return event; case BX_SYNC_EVT_ASK_PARAM: param = event->u.param.param; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc --- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200 +++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100 @@ -2,7 +2,7 @@ // $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2014 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -50,11 +50,25 @@ else return "?"; } +static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" }; + const char* iofunctions::getaction(int i) const { - static const char *name[] = { "ignore", "report", "ask", "fatal" }; assert (i>=ACT_IGNORE && i<N_ACT); - return name[i]; + return act_name[i]; +} + +int iofunctions::isaction(const char *val) const +{ + int action = -1; + + for (int i = 0; i < N_ACT; i++) { + if (!strcmp(val, act_name[i])) { + action = ACT_IGNORE + i; + break; + } + } + return action; } void iofunctions::flush(void) @@ -414,6 +428,11 @@ logio->out(LOGLEV_ERROR, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_ERROR] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_ERROR, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_ERROR] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_ERROR, prefix, fmt, ap); @@ -438,6 +457,11 @@ logio->out(LOGLEV_PANIC, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_PANIC] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_PANIC, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_PANIC] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_PANIC, prefix, fmt, ap); @@ -465,6 +489,36 @@ // the actions ask() and fatal() are not supported here } +void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap) +{ + // Guard against reentry on warn() function. The danger is that some + // function that's called within warn() could trigger another + // BX_ERROR that could call warn() again, leading to infinite + // recursion and infinite asks. + static char in_warn_already = 0; + char buf1[1024]; + if (in_warn_already) { + fprintf(stderr, "logfunctions::warn() should not reenter!!\n"); + return; + } + in_warn_already = 1; + vsnprintf(buf1, sizeof(buf1), fmt, ap); + // FIXME: facility set to 0 because it's unknown. + + // update vga screen. This is useful because sometimes useful messages + // are printed on the screen just before a panic. It's also potentially + // dangerous if this function calls ask again... That's why I added + // the reentry check above. + SIM->refresh_vga(); + + // ensure the text screen is showing + SIM->set_display_mode(DISP_MODE_CONFIG); + SIM->log_warn(prefix, level, buf1); + // return to simulation mode + SIM->set_display_mode(DISP_MODE_SIM); + in_warn_already = 0; +} + void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap) { // Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
int bx_real_sim_c::is_action_name(const char *val)
{
return io->isaction(val);
}
const char *bx_real_sim_c::get_log_level_name(int level)
{
return io->getlevel(level);
}
2008-09-20 01:31:08 +04:00
void bx_real_sim_c::quit_sim(int code)
{
BX_INFO(("quit_sim called with exit code %d", code));
exit_code = code;
io->exit_log();
// use longjmp to quit cleanly, no matter where in the stack we are.
if (quit_context != NULL) {
longjmp(*quit_context, 1);
BX_PANIC(("in bx_real_sim_c::quit_sim, longjmp should never return"));
} else {
// use exit() to stop the application.
if (!code)
BX_PANIC(("Quit simulation command"));
::exit(exit_code);
}
}
int bx_real_sim_c::get_default_rc(char *path, int len)
{
char *rc = bx_find_bochsrc();
if (rc == NULL) return -1;
strncpy(path, rc, len);
path[len-1] = 0;
return 0;
}
int bx_real_sim_c::read_rc(const char *rc)
{
return bx_read_configuration(rc);
}
// return values:
// 0: written ok
// -1: failed
// -2: already exists, and overwrite was off
int bx_real_sim_c::write_rc(const char *rc, int overwrite)
{
return bx_write_configuration(rc, overwrite);
}
int bx_real_sim_c::get_log_file(char *path, int len)
{
strncpy(path, SIM->get_param_string(BXPN_LOG_FILENAME)->getptr(), len);
return 0;
}
2009-11-08 23:47:03 +03:00
int bx_real_sim_c::set_log_file(const char *path)
{
SIM->get_param_string(BXPN_LOG_FILENAME)->set(path);
return 0;
}
int bx_real_sim_c::get_log_prefix(char *prefix, int len)
{
strncpy(prefix, SIM->get_param_string(BXPN_LOG_PREFIX)->getptr(), len);
return 0;
}
2009-11-08 23:47:03 +03:00
int bx_real_sim_c::set_log_prefix(const char *prefix)
{
SIM->get_param_string(BXPN_LOG_PREFIX)->set(prefix);
return 0;
}
int bx_real_sim_c::get_debugger_log_file(char *path, int len)
{
strncpy(path, SIM->get_param_string(BXPN_DEBUGGER_LOG_FILENAME)->getptr(), len);
return 0;
}
2009-11-08 23:47:03 +03:00
int bx_real_sim_c::set_debugger_log_file(const char *path)
{
SIM->get_param_string(BXPN_DEBUGGER_LOG_FILENAME)->set(path);
return 0;
}
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 };
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 };
const char *media_status_names[] = { "ejected", "inserted", NULL };
2007-10-25 03:09:59 +04:00
const char *bochs_bootdisk_names[] = { "none", "floppy", "disk","cdrom", "network", NULL };
const char *sound_driver_names[] = {
"dummy",
#if BX_HAVE_SOUND_ALSA
"alsa",
#endif
#if BX_HAVE_SOUND_OSS
"oss",
#endif
#if BX_HAVE_SOUND_OSX
"osx",
#endif
#if BX_HAVE_SOUND_SDL
"sdl",
#endif
#if BX_HAVE_SOUND_WIN
"win",
#endif
"file",
NULL
};
const char *hdimage_mode_names[] = {
"flat",
"concat",
"external",
"dll",
"sparse",
"vmware3",
"vmware4",
"undoable",
"growing",
"volatile",
"vvfat",
"vpc",
"vbox",
NULL
};
int bx_real_sim_c::hdimage_get_mode(const char *mode)
{
for (int i = 0; i <= BX_HDIMAGE_MODE_LAST; i++) {
if (!strcmp(mode, hdimage_mode_names[i])) return i;
}
return -1;
}
void bx_real_sim_c::set_notify_callback(bxevent_handler func, void *arg)
{
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
bxevent_callback = func;
bxevent_callback_data = arg;
}
void bx_real_sim_c::get_notify_callback(bxevent_handler *func, void **arg)
2002-09-23 20:57:45 +04:00
{
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
*func = bxevent_callback;
*arg = bxevent_callback_data;
2002-09-23 20:57:45 +04:00
}
BxEvent *bx_real_sim_c::sim_to_ci_event(BxEvent *event)
{
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
if (bxevent_callback == NULL) {
BX_ERROR(("notify called, but no bxevent_callback function is registered"));
return NULL;
2001-06-12 00:51:15 +04:00
} else {
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
return (*bxevent_callback)(bxevent_callback_data, event);
}
}
int bx_real_sim_c::log_dlg(const char *prefix, int level, const char *msg, int mode)
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h --- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200 +++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100 @@ -2,7 +2,7 @@ // $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2015 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -276,8 +276,9 @@ void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); - void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status); - void ask (int level, const char *prefix, const char *fmt, va_list ap); + void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status); + void warn(int level, const char *prefix, const char *fmt, va_list ap); + void ask(int level, const char *prefix, const char *fmt, va_list ap); void put(const char *p); void put(const char *n, const char *p); void setio(class iofunctions *); @@ -334,7 +335,8 @@ void set_log_action(int loglevel, int action); const char *getlevel(int i) const; const char *getaction(int i) const; - + int isaction(const char *val) const; + protected: int n_logfn; #define MAX_LOGFNS 512 diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES --- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100 +++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100 @@ -1,5 +1,8 @@ Changes after 2.6.8 release: +- General + - Added new log action "warn", designed to show a message box on error events. + - Configure and compile - Added Android host platform support. diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc --- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200 +++ ./config.cc 2016-12-27 19:53:10.461420368 +0100 @@ -2062,15 +2062,8 @@ actstr = strtok(NULL, ""); if (actstr != NULL) { def_action = !strcmp(module, "action"); - if (!strcmp(actstr, "fatal")) - action = ACT_FATAL; - else if (!strcmp (actstr, "report")) - action = ACT_REPORT; - else if (!strcmp (actstr, "ignore")) - action = ACT_IGNORE; - else if (!strcmp (actstr, "ask")) - action = ACT_ASK; - else { + action = SIM->is_action_name(actstr); + if (action < ACT_IGNORE) { PARSE_ERR(("%s: %s directive malformed.", context, params[0])); free(param); return -1; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc --- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200 +++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100 @@ -2,7 +2,7 @@ // $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2014-2015 The Bochs Project +// Copyright (C) 2014-2016 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 @@ -1478,20 +1478,16 @@ SDL_MessageBoxData msgboxdata; SDL_MessageBoxButtonData buttondata[4]; int level, retcode; -#if BX_DEBUGGER || BX_GDBSTUB - int defbtn = 3; -#else - int defbtn = 2; -#endif char message[512]; level = event->u.logmsg.level; - sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg); + sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); msgboxdata.flags = SDL_MESSAGEBOX_ERROR; msgboxdata.window = window; msgboxdata.title = SIM->get_log_level_name(level); msgboxdata.message = message; - msgboxdata.numbuttons = defbtn + 1; + msgboxdata.numbuttons = 2; msgboxdata.buttons = buttondata; msgboxdata.colorScheme = NULL; buttondata[0].flags = 0; @@ -1500,14 +1496,18 @@ buttondata[1].flags = 0; buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS; buttondata[1].text = "Alwayscont"; + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + msgboxdata.numbuttons = 3; + buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; + buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE; + buttondata[2].text = "Quit"; #if BX_DEBUGGER || BX_GDBSTUB - buttondata[2].flags = 0; - buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; - buttondata[2].text = "Debugger"; -#endif - buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; - buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE; - buttondata[defbtn].text = "Quit"; + msgboxdata.numbuttons = 4; + buttondata[3].flags = 0; + buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; + buttondata[3].text = "Debugger"; +#endif + } if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) { return -1; } else { diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc --- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100 +++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100 @@ -2,7 +2,7 @@ // $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2015 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -100,6 +100,7 @@ virtual int get_log_action(int mod, int level); virtual void set_log_action(int mod, int level, int action); virtual const char *get_action_name(int action); + virtual int is_action_name(const char *val); virtual int get_default_log_action(int level) { return logfunctions::get_default_action(level); } @@ -123,6 +124,7 @@ 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_warn(const char *prefix, int level, const char *msg); virtual int log_ask(const char *prefix, int level, const char *msg); virtual void log_msg(const char *prefix, int level, const char *msg); virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; } @@ -420,6 +422,11 @@ return io->getaction(action); } +int bx_real_sim_c::is_action_name(const char *val) +{ + return io->isaction(val); +} + const char *bx_real_sim_c::get_log_level_name(int level) { return io->getlevel(level); @@ -575,6 +582,21 @@ } } +int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg) +{ + BxEvent be; + be.type = BX_SYNC_EVT_LOG_ASK; + be.u.logmsg.prefix = prefix; + be.u.logmsg.level = level; + be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN; + // default return value in case something goes wrong. + be.retcode = BX_LOG_NOTIFY_FAILED; + // calling notify + sim_to_ci_event(&be); + return be.retcode; +} + // returns 0 for continue, 1 for alwayscontinue, 2 for die. int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg) { @@ -583,6 +605,7 @@ be.u.logmsg.prefix = prefix; be.u.logmsg.level = level; be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_ASKDLG; // default return value in case something goes wrong. be.retcode = BX_LOG_NOTIFY_FAILED; // calling notify @@ -1157,16 +1180,10 @@ } else if (!strncmp(string, "PANIC=", 6)) { type = LOGLEV_PANIC; } - 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; + action = is_action_name(string+j); + if (action >= ACT_IGNORE) { + set_log_action(dev, type, action); } - set_log_action(dev, type, action); } else { if (i == 1) { BX_ERROR(("restore_logopts(): log module '%s' not found", devname)); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h --- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200 +++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100 @@ -168,6 +168,7 @@ typedef enum { ACT_IGNORE = 0, ACT_REPORT, + ACT_WARN, ACT_ASK, ACT_FATAL, N_ACT @@ -178,11 +179,11 @@ // normally all action choices are available for all event types. The exclude // expression allows some choices to be eliminated if they don't make any // sense. For example, it would be stupid to ignore a panic. -#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ - /* can't die or ask, on debug or info events */ \ - (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \ - /* can't ignore panics */ \ - || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ +#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ + /* can't die, ask or warn, on debug or info events */ \ + (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \ + /* can't ignore panics */ \ + || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ ) // floppy / cdrom media status @@ -392,6 +393,7 @@ // synchronizing threads, etc. for each. typedef struct { Bit8u level; + Bit8u flag; const char *prefix; const char *msg; } BxLogMsgEvent; @@ -419,6 +421,12 @@ BX_LOG_NOTIFY_FAILED }; +enum { + BX_LOG_ASK_ASKDLG, + BX_LOG_ASK_MSGBOX_WARN, + BX_LOG_ASK_MSGBOX_QUIT +}; + // Event type: BX_SYNC_EVT_GET_DBG_COMMAND // // This is a synchronous event sent from the simulator to the debugger @@ -675,6 +683,7 @@ virtual int get_default_log_action(int level) {return -1;} virtual void set_default_log_action(int level, int action) {} virtual const char *get_action_name(int action) {return NULL;} + virtual int is_action_name(const char *val) {return -1;} virtual const char *get_log_level_name(int level) {return NULL;} virtual int get_max_log_level() {return -1;} @@ -715,6 +724,9 @@ // send an event from the simulator to the CI. virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;} + // called from simulator when it hits errors, to warn the user + // before continuing simulation + virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;} // called from simulator when it hits serious errors, to ask if the user // wants to continue or not virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;} diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc --- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100 +++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100 @@ -2,7 +2,7 @@ // $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2013 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -552,8 +552,8 @@ } static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] "; -static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" }; -static int log_level_n_choices_normal = 4; +static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" }; +static int log_level_n_choices_normal = N_ACT; void bx_log_options(int individual) { @@ -589,7 +589,7 @@ bx_print_log_action_table(); for (int level=0; level<SIM->get_max_log_level(); level++) { char prompt[1024]; - int action, default_action = 4; // default to no change + int action, default_action = N_ACT; // default to no change sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level)); // do show the no change choice (choices=4) if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0) @@ -718,47 +718,50 @@ event->retcode = event->u.param.param->text_ask(stdin, stderr); return event; case BX_SYNC_EVT_LOG_ASK: - { - int level = event->u.logmsg.level; - fprintf(stderr, "========================================================================\n"); - fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); - fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); - fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); - fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); - fprintf(stderr, " cont - continue execution\n"); - fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); - fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); - fprintf(stderr, " die - stop execution now\n"); - fprintf(stderr, " abort - dump core %s\n", - BX_HAVE_ABORT ? "" : "(Disabled)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + int level = event->u.logmsg.level; + fprintf(stderr, "========================================================================\n"); + fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); + fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); + fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); + fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); + fprintf(stderr, " cont - continue execution\n"); + fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); + fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); + fprintf(stderr, " die - stop execution now\n"); + fprintf(stderr, " abort - dump core %s\n", + BX_HAVE_ABORT ? "" : "(Disabled)"); #if BX_DEBUGGER - fprintf(stderr, " debug - continue and return to bochs debugger\n"); + fprintf(stderr, " debug - continue and return to bochs debugger\n"); #endif #if BX_GDBSTUB - fprintf(stderr, " debug - hand control to gdb\n"); + fprintf(stderr, " debug - hand control to gdb\n"); #endif - int choice; + int choice; ask: - if (ask_menu("Choose one of the actions above: [%s] ", "", - log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) - event->retcode = -1; - // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. - if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; - fflush(stdout); - fflush(stderr); - event->retcode = choice; - } - return event; - case BX_ASYNC_EVT_REFRESH: - case BX_ASYNC_EVT_DBG_MSG: - case BX_ASYNC_EVT_LOG_MSG: - // The text mode interface does not use these events, so just ignore - // them. - return event; - default: - fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); - return event; + if (ask_menu("Choose one of the actions above: [%s] ", "", + log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) + event->retcode = -1; + // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. + if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; + fflush(stdout); + fflush(stderr); + event->retcode = choice; + } else { + // warning prompt not implemented + event->retcode = 0; + } + return event; + case BX_ASYNC_EVT_REFRESH: + case BX_ASYNC_EVT_DBG_MSG: + case BX_ASYNC_EVT_LOG_MSG: + // The text mode interface does not use these events, so just ignore + // them. + return event; + default: + fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); + return event; } assert(0); // switch statement should return } diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc --- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200 +++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100 @@ -2,7 +2,7 @@ // $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2003-2014 The Bochs Project +// Copyright (C) 2003-2016 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 @@ -27,7 +27,7 @@ #include "win32res.h" #include "win32paramdlg.h" -const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"}; +const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"}; HWND GetBochsWindow() { @@ -97,12 +97,16 @@ SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue"); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); #if BX_DEBUGGER - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); #endif - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + } else { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0); + } SetFocus(GetDlgItem(hDlg, IDASKLIST)); return FALSE; case WM_CLOSE: diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc --- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100 +++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -208,7 +208,6 @@ : wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3}; static wxString names[] = ADVLOG_OPTS_TYPE_NAMES; SetTitle(ADVLOG_OPTS_TITLE); vertSizer = new wxBoxSizer(wxVERTICAL); @@ -1563,7 +1562,7 @@ bool includeNoChange) { static wxString choices[] = LOG_OPTS_CHOICES; - static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4}; + static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5}; wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize); int lastChoice = 0; // remember index of last choice int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h --- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100 +++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $ //////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -354,10 +354,10 @@ #define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?") #define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") } #define LOG_OPTS_N_TYPES 4 -#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") } -#define LOG_OPTS_N_CHOICES_NORMAL 4 -#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change" -#define LOG_OPTS_NO_CHANGE 4 // index of "no change" +#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") } +#define LOG_OPTS_N_CHOICES_NORMAL 5 +#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change" +#define LOG_OPTS_NO_CHANGE 5 // index of "no change" #define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".") wxFlexGridSizer *gridSizer; wxChoice *action[LOG_OPTS_N_TYPES]; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc --- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100 +++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100 @@ -2,7 +2,7 @@ // $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -1158,6 +1158,10 @@ #if !BX_DEBUGGER && !BX_GDBSTUB dlg.EnableButton(dlg.DEBUG, FALSE); #endif + if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) { + dlg.EnableButton(dlg.DIE, FALSE); + dlg.EnableButton(dlg.DUMP, FALSE); + } dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8)); dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8)); int n = dlg.ShowModal(); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc --- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100 +++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100 @@ -2687,11 +2687,7 @@ } else { size_x = 30 + maxlen * 6; } - if (lines < 3) { - size_y = 90; - } else { - size_y = 60 + lines * 15; - } + size_y = 70 + lines * 15; x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y, (mode == XDLG_SIMPLE) ? 1 : 2); ypos = 34; @@ -2729,11 +2725,21 @@ bx_param_string_c *sparam; bx_param_enum_c *eparam; bx_list_c *list; + char message[256]; switch (event->type) { case BX_SYNC_EVT_LOG_ASK: - event->retcode = x11_ask_dialog(event); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + event->retcode = x11_ask_dialog(event); + } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) { + const char *title = SIM->get_log_level_name(event->u.logmsg.level); + sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); + bx_param_bool_c bparam(NULL, "warn", title, message, 1); + x11_message_box(&bparam, XDLG_SIMPLE); + event->retcode = 0; + } return event; case BX_SYNC_EVT_ASK_PARAM: param = event->u.param.param; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc --- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200 +++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100 @@ -2,7 +2,7 @@ // $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2014 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -50,11 +50,25 @@ else return "?"; } +static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" }; + const char* iofunctions::getaction(int i) const { - static const char *name[] = { "ignore", "report", "ask", "fatal" }; assert (i>=ACT_IGNORE && i<N_ACT); - return name[i]; + return act_name[i]; +} + +int iofunctions::isaction(const char *val) const +{ + int action = -1; + + for (int i = 0; i < N_ACT; i++) { + if (!strcmp(val, act_name[i])) { + action = ACT_IGNORE + i; + break; + } + } + return action; } void iofunctions::flush(void) @@ -414,6 +428,11 @@ logio->out(LOGLEV_ERROR, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_ERROR] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_ERROR, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_ERROR] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_ERROR, prefix, fmt, ap); @@ -438,6 +457,11 @@ logio->out(LOGLEV_PANIC, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_PANIC] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_PANIC, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_PANIC] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_PANIC, prefix, fmt, ap); @@ -465,6 +489,36 @@ // the actions ask() and fatal() are not supported here } +void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap) +{ + // Guard against reentry on warn() function. The danger is that some + // function that's called within warn() could trigger another + // BX_ERROR that could call warn() again, leading to infinite + // recursion and infinite asks. + static char in_warn_already = 0; + char buf1[1024]; + if (in_warn_already) { + fprintf(stderr, "logfunctions::warn() should not reenter!!\n"); + return; + } + in_warn_already = 1; + vsnprintf(buf1, sizeof(buf1), fmt, ap); + // FIXME: facility set to 0 because it's unknown. + + // update vga screen. This is useful because sometimes useful messages + // are printed on the screen just before a panic. It's also potentially + // dangerous if this function calls ask again... That's why I added + // the reentry check above. + SIM->refresh_vga(); + + // ensure the text screen is showing + SIM->set_display_mode(DISP_MODE_CONFIG); + SIM->log_warn(prefix, level, buf1); + // return to simulation mode + SIM->set_display_mode(DISP_MODE_SIM); + in_warn_already = 0; +} + void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap) { // Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
{
BxEvent be;
be.type = BX_SYNC_EVT_LOG_DLG;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h --- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200 +++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100 @@ -2,7 +2,7 @@ // $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2015 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -276,8 +276,9 @@ void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); - void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status); - void ask (int level, const char *prefix, const char *fmt, va_list ap); + void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status); + void warn(int level, const char *prefix, const char *fmt, va_list ap); + void ask(int level, const char *prefix, const char *fmt, va_list ap); void put(const char *p); void put(const char *n, const char *p); void setio(class iofunctions *); @@ -334,7 +335,8 @@ void set_log_action(int loglevel, int action); const char *getlevel(int i) const; const char *getaction(int i) const; - + int isaction(const char *val) const; + protected: int n_logfn; #define MAX_LOGFNS 512 diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES --- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100 +++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100 @@ -1,5 +1,8 @@ Changes after 2.6.8 release: +- General + - Added new log action "warn", designed to show a message box on error events. + - Configure and compile - Added Android host platform support. diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc --- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200 +++ ./config.cc 2016-12-27 19:53:10.461420368 +0100 @@ -2062,15 +2062,8 @@ actstr = strtok(NULL, ""); if (actstr != NULL) { def_action = !strcmp(module, "action"); - if (!strcmp(actstr, "fatal")) - action = ACT_FATAL; - else if (!strcmp (actstr, "report")) - action = ACT_REPORT; - else if (!strcmp (actstr, "ignore")) - action = ACT_IGNORE; - else if (!strcmp (actstr, "ask")) - action = ACT_ASK; - else { + action = SIM->is_action_name(actstr); + if (action < ACT_IGNORE) { PARSE_ERR(("%s: %s directive malformed.", context, params[0])); free(param); return -1; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc --- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200 +++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100 @@ -2,7 +2,7 @@ // $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2014-2015 The Bochs Project +// Copyright (C) 2014-2016 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 @@ -1478,20 +1478,16 @@ SDL_MessageBoxData msgboxdata; SDL_MessageBoxButtonData buttondata[4]; int level, retcode; -#if BX_DEBUGGER || BX_GDBSTUB - int defbtn = 3; -#else - int defbtn = 2; -#endif char message[512]; level = event->u.logmsg.level; - sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg); + sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); msgboxdata.flags = SDL_MESSAGEBOX_ERROR; msgboxdata.window = window; msgboxdata.title = SIM->get_log_level_name(level); msgboxdata.message = message; - msgboxdata.numbuttons = defbtn + 1; + msgboxdata.numbuttons = 2; msgboxdata.buttons = buttondata; msgboxdata.colorScheme = NULL; buttondata[0].flags = 0; @@ -1500,14 +1496,18 @@ buttondata[1].flags = 0; buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS; buttondata[1].text = "Alwayscont"; + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + msgboxdata.numbuttons = 3; + buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; + buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE; + buttondata[2].text = "Quit"; #if BX_DEBUGGER || BX_GDBSTUB - buttondata[2].flags = 0; - buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; - buttondata[2].text = "Debugger"; -#endif - buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; - buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE; - buttondata[defbtn].text = "Quit"; + msgboxdata.numbuttons = 4; + buttondata[3].flags = 0; + buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; + buttondata[3].text = "Debugger"; +#endif + } if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) { return -1; } else { diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc --- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100 +++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100 @@ -2,7 +2,7 @@ // $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2015 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -100,6 +100,7 @@ virtual int get_log_action(int mod, int level); virtual void set_log_action(int mod, int level, int action); virtual const char *get_action_name(int action); + virtual int is_action_name(const char *val); virtual int get_default_log_action(int level) { return logfunctions::get_default_action(level); } @@ -123,6 +124,7 @@ 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_warn(const char *prefix, int level, const char *msg); virtual int log_ask(const char *prefix, int level, const char *msg); virtual void log_msg(const char *prefix, int level, const char *msg); virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; } @@ -420,6 +422,11 @@ return io->getaction(action); } +int bx_real_sim_c::is_action_name(const char *val) +{ + return io->isaction(val); +} + const char *bx_real_sim_c::get_log_level_name(int level) { return io->getlevel(level); @@ -575,6 +582,21 @@ } } +int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg) +{ + BxEvent be; + be.type = BX_SYNC_EVT_LOG_ASK; + be.u.logmsg.prefix = prefix; + be.u.logmsg.level = level; + be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN; + // default return value in case something goes wrong. + be.retcode = BX_LOG_NOTIFY_FAILED; + // calling notify + sim_to_ci_event(&be); + return be.retcode; +} + // returns 0 for continue, 1 for alwayscontinue, 2 for die. int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg) { @@ -583,6 +605,7 @@ be.u.logmsg.prefix = prefix; be.u.logmsg.level = level; be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_ASKDLG; // default return value in case something goes wrong. be.retcode = BX_LOG_NOTIFY_FAILED; // calling notify @@ -1157,16 +1180,10 @@ } else if (!strncmp(string, "PANIC=", 6)) { type = LOGLEV_PANIC; } - 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; + action = is_action_name(string+j); + if (action >= ACT_IGNORE) { + set_log_action(dev, type, action); } - set_log_action(dev, type, action); } else { if (i == 1) { BX_ERROR(("restore_logopts(): log module '%s' not found", devname)); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h --- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200 +++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100 @@ -168,6 +168,7 @@ typedef enum { ACT_IGNORE = 0, ACT_REPORT, + ACT_WARN, ACT_ASK, ACT_FATAL, N_ACT @@ -178,11 +179,11 @@ // normally all action choices are available for all event types. The exclude // expression allows some choices to be eliminated if they don't make any // sense. For example, it would be stupid to ignore a panic. -#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ - /* can't die or ask, on debug or info events */ \ - (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \ - /* can't ignore panics */ \ - || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ +#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ + /* can't die, ask or warn, on debug or info events */ \ + (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \ + /* can't ignore panics */ \ + || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ ) // floppy / cdrom media status @@ -392,6 +393,7 @@ // synchronizing threads, etc. for each. typedef struct { Bit8u level; + Bit8u flag; const char *prefix; const char *msg; } BxLogMsgEvent; @@ -419,6 +421,12 @@ BX_LOG_NOTIFY_FAILED }; +enum { + BX_LOG_ASK_ASKDLG, + BX_LOG_ASK_MSGBOX_WARN, + BX_LOG_ASK_MSGBOX_QUIT +}; + // Event type: BX_SYNC_EVT_GET_DBG_COMMAND // // This is a synchronous event sent from the simulator to the debugger @@ -675,6 +683,7 @@ virtual int get_default_log_action(int level) {return -1;} virtual void set_default_log_action(int level, int action) {} virtual const char *get_action_name(int action) {return NULL;} + virtual int is_action_name(const char *val) {return -1;} virtual const char *get_log_level_name(int level) {return NULL;} virtual int get_max_log_level() {return -1;} @@ -715,6 +724,9 @@ // send an event from the simulator to the CI. virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;} + // called from simulator when it hits errors, to warn the user + // before continuing simulation + virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;} // called from simulator when it hits serious errors, to ask if the user // wants to continue or not virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;} diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc --- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100 +++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100 @@ -2,7 +2,7 @@ // $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2013 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -552,8 +552,8 @@ } static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] "; -static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" }; -static int log_level_n_choices_normal = 4; +static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" }; +static int log_level_n_choices_normal = N_ACT; void bx_log_options(int individual) { @@ -589,7 +589,7 @@ bx_print_log_action_table(); for (int level=0; level<SIM->get_max_log_level(); level++) { char prompt[1024]; - int action, default_action = 4; // default to no change + int action, default_action = N_ACT; // default to no change sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level)); // do show the no change choice (choices=4) if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0) @@ -718,47 +718,50 @@ event->retcode = event->u.param.param->text_ask(stdin, stderr); return event; case BX_SYNC_EVT_LOG_ASK: - { - int level = event->u.logmsg.level; - fprintf(stderr, "========================================================================\n"); - fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); - fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); - fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); - fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); - fprintf(stderr, " cont - continue execution\n"); - fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); - fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); - fprintf(stderr, " die - stop execution now\n"); - fprintf(stderr, " abort - dump core %s\n", - BX_HAVE_ABORT ? "" : "(Disabled)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + int level = event->u.logmsg.level; + fprintf(stderr, "========================================================================\n"); + fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); + fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); + fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); + fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); + fprintf(stderr, " cont - continue execution\n"); + fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); + fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); + fprintf(stderr, " die - stop execution now\n"); + fprintf(stderr, " abort - dump core %s\n", + BX_HAVE_ABORT ? "" : "(Disabled)"); #if BX_DEBUGGER - fprintf(stderr, " debug - continue and return to bochs debugger\n"); + fprintf(stderr, " debug - continue and return to bochs debugger\n"); #endif #if BX_GDBSTUB - fprintf(stderr, " debug - hand control to gdb\n"); + fprintf(stderr, " debug - hand control to gdb\n"); #endif - int choice; + int choice; ask: - if (ask_menu("Choose one of the actions above: [%s] ", "", - log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) - event->retcode = -1; - // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. - if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; - fflush(stdout); - fflush(stderr); - event->retcode = choice; - } - return event; - case BX_ASYNC_EVT_REFRESH: - case BX_ASYNC_EVT_DBG_MSG: - case BX_ASYNC_EVT_LOG_MSG: - // The text mode interface does not use these events, so just ignore - // them. - return event; - default: - fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); - return event; + if (ask_menu("Choose one of the actions above: [%s] ", "", + log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) + event->retcode = -1; + // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. + if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; + fflush(stdout); + fflush(stderr); + event->retcode = choice; + } else { + // warning prompt not implemented + event->retcode = 0; + } + return event; + case BX_ASYNC_EVT_REFRESH: + case BX_ASYNC_EVT_DBG_MSG: + case BX_ASYNC_EVT_LOG_MSG: + // The text mode interface does not use these events, so just ignore + // them. + return event; + default: + fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); + return event; } assert(0); // switch statement should return } diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc --- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200 +++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100 @@ -2,7 +2,7 @@ // $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2003-2014 The Bochs Project +// Copyright (C) 2003-2016 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 @@ -27,7 +27,7 @@ #include "win32res.h" #include "win32paramdlg.h" -const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"}; +const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"}; HWND GetBochsWindow() { @@ -97,12 +97,16 @@ SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue"); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); #if BX_DEBUGGER - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); #endif - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + } else { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0); + } SetFocus(GetDlgItem(hDlg, IDASKLIST)); return FALSE; case WM_CLOSE: diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc --- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100 +++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -208,7 +208,6 @@ : wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3}; static wxString names[] = ADVLOG_OPTS_TYPE_NAMES; SetTitle(ADVLOG_OPTS_TITLE); vertSizer = new wxBoxSizer(wxVERTICAL); @@ -1563,7 +1562,7 @@ bool includeNoChange) { static wxString choices[] = LOG_OPTS_CHOICES; - static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4}; + static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5}; wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize); int lastChoice = 0; // remember index of last choice int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h --- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100 +++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $ //////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -354,10 +354,10 @@ #define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?") #define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") } #define LOG_OPTS_N_TYPES 4 -#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") } -#define LOG_OPTS_N_CHOICES_NORMAL 4 -#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change" -#define LOG_OPTS_NO_CHANGE 4 // index of "no change" +#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") } +#define LOG_OPTS_N_CHOICES_NORMAL 5 +#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change" +#define LOG_OPTS_NO_CHANGE 5 // index of "no change" #define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".") wxFlexGridSizer *gridSizer; wxChoice *action[LOG_OPTS_N_TYPES]; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc --- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100 +++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100 @@ -2,7 +2,7 @@ // $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -1158,6 +1158,10 @@ #if !BX_DEBUGGER && !BX_GDBSTUB dlg.EnableButton(dlg.DEBUG, FALSE); #endif + if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) { + dlg.EnableButton(dlg.DIE, FALSE); + dlg.EnableButton(dlg.DUMP, FALSE); + } dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8)); dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8)); int n = dlg.ShowModal(); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc --- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100 +++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100 @@ -2687,11 +2687,7 @@ } else { size_x = 30 + maxlen * 6; } - if (lines < 3) { - size_y = 90; - } else { - size_y = 60 + lines * 15; - } + size_y = 70 + lines * 15; x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y, (mode == XDLG_SIMPLE) ? 1 : 2); ypos = 34; @@ -2729,11 +2725,21 @@ bx_param_string_c *sparam; bx_param_enum_c *eparam; bx_list_c *list; + char message[256]; switch (event->type) { case BX_SYNC_EVT_LOG_ASK: - event->retcode = x11_ask_dialog(event); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + event->retcode = x11_ask_dialog(event); + } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) { + const char *title = SIM->get_log_level_name(event->u.logmsg.level); + sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); + bx_param_bool_c bparam(NULL, "warn", title, message, 1); + x11_message_box(&bparam, XDLG_SIMPLE); + event->retcode = 0; + } return event; case BX_SYNC_EVT_ASK_PARAM: param = event->u.param.param; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc --- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200 +++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100 @@ -2,7 +2,7 @@ // $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2014 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -50,11 +50,25 @@ else return "?"; } +static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" }; + const char* iofunctions::getaction(int i) const { - static const char *name[] = { "ignore", "report", "ask", "fatal" }; assert (i>=ACT_IGNORE && i<N_ACT); - return name[i]; + return act_name[i]; +} + +int iofunctions::isaction(const char *val) const +{ + int action = -1; + + for (int i = 0; i < N_ACT; i++) { + if (!strcmp(val, act_name[i])) { + action = ACT_IGNORE + i; + break; + } + } + return action; } void iofunctions::flush(void) @@ -414,6 +428,11 @@ logio->out(LOGLEV_ERROR, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_ERROR] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_ERROR, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_ERROR] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_ERROR, prefix, fmt, ap); @@ -438,6 +457,11 @@ logio->out(LOGLEV_PANIC, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_PANIC] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_PANIC, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_PANIC] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_PANIC, prefix, fmt, ap); @@ -465,6 +489,36 @@ // the actions ask() and fatal() are not supported here } +void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap) +{ + // Guard against reentry on warn() function. The danger is that some + // function that's called within warn() could trigger another + // BX_ERROR that could call warn() again, leading to infinite + // recursion and infinite asks. + static char in_warn_already = 0; + char buf1[1024]; + if (in_warn_already) { + fprintf(stderr, "logfunctions::warn() should not reenter!!\n"); + return; + } + in_warn_already = 1; + vsnprintf(buf1, sizeof(buf1), fmt, ap); + // FIXME: facility set to 0 because it's unknown. + + // update vga screen. This is useful because sometimes useful messages + // are printed on the screen just before a panic. It's also potentially + // dangerous if this function calls ask again... That's why I added + // the reentry check above. + SIM->refresh_vga(); + + // ensure the text screen is showing + SIM->set_display_mode(DISP_MODE_CONFIG); + SIM->log_warn(prefix, level, buf1); + // return to simulation mode + SIM->set_display_mode(DISP_MODE_SIM); + in_warn_already = 0; +} + void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap) { // Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
be.u.logmsg.prefix = prefix;
be.u.logmsg.level = level;
be.u.logmsg.msg = msg;
be.u.logmsg.mode = mode;
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
// default return value in case something goes wrong.
be.retcode = BX_LOG_NOTIFY_FAILED;
// calling notify
sim_to_ci_event(&be);
return be.retcode;
}
void bx_real_sim_c::log_msg(const char *prefix, int level, const char *msg)
{
if (SIM->has_log_viewer()) {
// send message to the log viewer
char *logmsg = new char[strlen(prefix) + strlen(msg) + 4];
sprintf(logmsg, "%s %s\n", prefix, msg);
BxEvent *event = new BxEvent();
event->type = BX_ASYNC_EVT_LOG_MSG;
event->u.logmsg.prefix = NULL;
event->u.logmsg.level = level;
event->u.logmsg.msg = logmsg;
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
// Called by simulator whenever it needs the user to choose a new value
// for a registered parameter. Create a synchronous ASK_PARAM event,
// 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.
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
{
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
BxEvent event;
event.type = BX_SYNC_EVT_ASK_PARAM;
event.u.param.param = param;
sim_to_ci_event(&event);
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
}
int bx_real_sim_c::ask_param(const char *pname)
{
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;
bx_param_filename_c param(NULL, "filename", prompt, "", the_default, maxlen);
param.set_options(param.get_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 = &param;
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)
{
BxEvent event;
char format[512];
bx_param_bool_c param(NULL, "yes_no", title, prompt, the_default);
sprintf(format, "%s\n\n%s [%%s] ", title, prompt);
param.set_ask_format(format);
event.type = BX_SYNC_EVT_ASK_PARAM;
event.u.param.param = &param;
sim_to_ci_event(&event);
if (event.retcode >= 0) {
return param.get();
} else {
return event.retcode;
}
}
void bx_real_sim_c::message_box(const char *title, const char *message)
{
BxEvent event;
event.type = BX_SYNC_EVT_MSG_BOX;
event.u.logmsg.prefix = title;
event.u.logmsg.msg = message;
sim_to_ci_event(&event);
}
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
{
// 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.
BxEvent tick;
tick.type = BX_SYNC_EVT_TICK;
sim_to_ci_event (&tick);
if (tick.retcode < 0) {
BX_INFO(("Bochs thread has been asked to quit."));
#if !BX_DEBUGGER
bx_atexit();
quit_sim(0);
#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.
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
}
// create a disk image file called filename, size=512 bytes * sectors.
// If overwrite is 0 and the file exists, returns -1 without changing it.
// 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.
//
// wxWidgets: This may be called from the gui thread.
int bx_real_sim_c::create_disk_image(const char *filename, int sectors, bx_bool overwrite)
{
FILE *fp;
if (!overwrite) {
// check for existence first
fp = fopen(filename, "r");
if (fp) {
// yes it exists
fclose(fp);
return -1;
}
}
fp = fopen(filename, "w");
if (fp == NULL) {
#ifdef HAVE_PERROR
char buffer[1024];
sprintf(buffer, "while opening '%s' for writing", filename);
perror(buffer);
// 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)
{
fclose(fp);
return -3;
}
fclose(fp);
return 0;
}
void bx_real_sim_c::refresh_ci()
{
if (SIM->has_debug_gui()) {
// It's an async event, so allocate a pointer and send it.
// The event will be freed by the recipient.
BxEvent *event = new BxEvent();
event->type = BX_ASYNC_EVT_REFRESH;
sim_to_ci_event(event);
}
- 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
}
bx_param_c *bx_real_sim_c::get_first_atadevice(Bit32u search_type)
{
char pname[80];
for (int channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
sprintf(pname, "ata.%d.resources.enabled", channel);
if (!SIM->get_param_bool(pname)->get())
continue;
for (int slave=0; slave<2; slave++) {
sprintf(pname, "ata.%d.%s.type", channel, (slave==0)?"master":"slave");
Bit32u type = SIM->get_param_enum(pname)->get();
if (type == search_type) {
sprintf(pname, "ata.%d.%s", channel, (slave==0)?"master":"slave");
return SIM->get_param(pname);
}
}
}
return NULL;
}
bx_bool bx_real_sim_c::is_pci_device(const char *name)
{
#if BX_SUPPORT_PCI
unsigned i, max_pci_slots = BX_N_PCI_SLOTS;
char devname[80];
char *device;
if (SIM->get_param_bool(BXPN_PCI_ENABLED)->get()) {
if (SIM->get_param_enum(BXPN_PCI_CHIPSET)->get() == BX_PCI_CHIPSET_I440BX) {
max_pci_slots = 4;
}
for (i = 0; i < max_pci_slots; i++) {
sprintf(devname, "pci.slot.%d", i+1);
device = SIM->get_param_string(devname)->getptr();
if ((strlen(device) > 0) && (!strcmp(name, device))) {
return 1;
}
}
}
#endif
return 0;
}
bx_bool bx_real_sim_c::is_agp_device(const char *name)
{
#if BX_SUPPORT_PCI
if (get_param_bool(BXPN_PCI_ENABLED)->get() &&
(SIM->get_param_enum(BXPN_PCI_CHIPSET)->get() == BX_PCI_CHIPSET_I440BX)) {
const char *device = SIM->get_param_string("pci.slot.5")->getptr();
if ((strlen(device) > 0) && (!strcmp(name, device))) {
return 1;
}
}
#endif
return 0;
}
- 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.
void bx_real_sim_c::debug_break()
{
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.
void bx_real_sim_c::debug_interpret_cmd(char *cmd)
{
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;
}
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
}
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;
BX_DEBUG(("asking for next debug command"));
sim_to_ci_event (&event);
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
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
{
if (SIM->has_debug_gui()) {
// send message to the gui debugger
BxEvent *event = new BxEvent();
event->type = BX_ASYNC_EVT_DBG_MSG;
event->u.logmsg.msg = text;
sim_to_ci_event(event);
} else {
// text mode debugger: just write to console
fputs(text, stdout);
}
- 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
void bx_real_sim_c::register_configuration_interface(
const char* name,
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
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;
}
int bx_real_sim_c::configuration_interface(const char *ignore, ci_command_t command)
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04: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();
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
if (!ci_callback) {
BX_PANIC(("no configuration interface was loaded"));
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
return -1;
}
if (strcmp(name, registered_ci_name) != 0) {
BX_PANIC(("siminterface does not support loading one configuration interface and then calling another"));
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
return -1;
}
if (!strcmp(name, "wx"))
wxsel = 1;
else
wxsel = 0;
bx_debug_gui = wxsel;
// enter configuration mode, just while running the configuration interface
set_display_mode(DISP_MODE_CONFIG);
int retval = (*ci_callback)(ci_callback_data, command);
set_display_mode(DISP_MODE_SIM);
return retval;
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
}
int bx_real_sim_c::begin_simulation(int argc, char *argv[])
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
{
return bx_begin_simulation(argc, argv);
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
}
int bx_real_sim_c::register_runtime_config_handler(void *dev, rt_conf_handler_t handler)
{
rt_conf_entry_t *rt_conf_entry = new rt_conf_entry_t;
rt_conf_entry->id = rt_conf_id;
rt_conf_entry->device = dev;
rt_conf_entry->handler = handler;
rt_conf_entry->next = NULL;
if (rt_conf_entries == NULL) {
rt_conf_entries = rt_conf_entry;
} else {
rt_conf_entry_t *temp = rt_conf_entries;
while (temp->next) {
temp = temp->next;
}
temp->next = rt_conf_entry;
}
return rt_conf_id++;
}
void bx_real_sim_c::unregister_runtime_config_handler(int id)
{
rt_conf_entry_t *prev = NULL, *curr = rt_conf_entries;
while (curr != NULL) {
if (curr->id == id) {
if (prev != NULL) {
prev->next = curr->next;
} else {
rt_conf_entries = curr->next;
}
delete curr;
break;
} else {
prev = curr;
curr = curr->next;
}
}
}
void bx_real_sim_c::update_runtime_options()
{
rt_conf_entry_t *temp = rt_conf_entries;
while (temp != NULL) {
temp->handler(temp->device);
temp = temp->next;
}
bx_gui->update_drive_status_buttons();
bx_virt_timer.set_realtime_delay();
}
bx_bool bx_real_sim_c::is_sim_thread()
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
{
if (is_sim_thread_func == NULL) return 1;
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
return (*is_sim_thread_func)();
}
// 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
// tests if stdin/stdout/stderr are usable and returns 0 if not.
bx_bool bx_real_sim_c::test_for_text_console()
{
#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.
if(!isatty(STDIN_FILENO)) return 0;
#endif
// default: yes
return 1;
}
bx_bool bx_real_sim_c::is_addon_option(const char *keyword)
{
addon_option_t *addon_option;
for (addon_option = addon_options; addon_option; addon_option = addon_option->next) {
if (!strcmp(addon_option->name, keyword)) return 1;
}
return 0;
}
bx_bool bx_real_sim_c::register_addon_option(const char *keyword, addon_option_parser_t parser,
addon_option_save_t save_func)
{
addon_option_t *addon_option = new addon_option_t;
addon_option->name = keyword;
addon_option->parser = parser;
addon_option->savefn = save_func;
addon_option->next = NULL;
if (addon_options == NULL) {
addon_options = addon_option;
} else {
addon_option_t *temp = addon_options;
while (temp->next) {
if (!strcmp(temp->name, keyword)) {
delete addon_option;
return 0;
}
temp = temp->next;
}
temp->next = addon_option;
}
return 1;
}
bx_bool bx_real_sim_c::unregister_addon_option(const char *keyword)
{
addon_option_t *addon_option, *prev = NULL;
for (addon_option = addon_options; addon_option; addon_option = addon_option->next) {
if (!strcmp(addon_option->name, keyword)) {
if (prev == NULL) {
addon_options = addon_option->next;
} else {
prev->next = addon_option->next;
}
delete addon_option;
return 1;
} else {
prev = addon_option;
}
}
return 0;
}
Bit32s bx_real_sim_c::parse_addon_option(const char *context, int num_params, char *params [])
{
for (addon_option_t *addon_option = addon_options; addon_option; addon_option = addon_option->next) {
if ((!strcmp(addon_option->name, params[0])) &&
(addon_option->parser != NULL)) {
return (*addon_option->parser)(context, num_params, params);
}
}
return -1;
}
Bit32s bx_real_sim_c::save_addon_options(FILE *fp)
{
for (addon_option_t *addon_option = addon_options; addon_option; addon_option = addon_option->next) {
if (addon_option->savefn != NULL) {
(*addon_option->savefn)(fp);
}
}
return 0;
}
void bx_real_sim_c::init_statistics()
{
if (get_statistics_root() == NULL) {
new bx_list_c(root_param, "statistics", "statistics");
}
}
void bx_real_sim_c::cleanup_statistics()
{
bx_list_c *list;
if ((list = get_statistics_root()) != NULL) {
list->clear();
}
}
void bx_real_sim_c::init_save_restore()
{
if (get_bochs_root() == NULL) {
new bx_list_c(root_param, "bochs", "subtree for save/restore");
}
}
void bx_real_sim_c::cleanup_save_restore()
{
bx_list_c *list = get_bochs_root();
if (list != NULL) {
list->clear();
}
}
bx_bool bx_real_sim_c::save_state(const char *checkpoint_path)
{
char sr_file[BX_PATHNAME_LEN];
char devname[20];
int dev, ndev = SIM->get_n_log_modules();
int type, ntype = SIM->get_max_log_level();
get_param_string(BXPN_RESTORE_PATH)->set(checkpoint_path);
sprintf(sr_file, "%s/config", checkpoint_path);
if (write_rc(sr_file, 1) < 0)
return 0;
sprintf(sr_file, "%s/logopts", checkpoint_path);
FILE *fp = fopen(sr_file, "w");
if (fp != NULL) {
for (dev=0; dev<ndev; dev++) {
strcpy(devname, get_logfn_name(dev));
if ((strlen(devname) > 0) && (strcmp(devname, "?"))) {
fprintf(fp, "%s: ", devname);
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);
} else {
return 0;
}
bx_list_c *sr_list = get_bochs_root();
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) {
save_sr_param(fp, sr_list->get(dev), checkpoint_path, 0);
fclose(fp);
} else {
return 0;
}
}
get_param_string(BXPN_RESTORE_PATH)->set("none");
return 1;
}
bx_bool bx_real_sim_c::restore_config()
{
char config[BX_PATHNAME_LEN];
sprintf(config, "%s/config", get_param_string(BXPN_RESTORE_PATH)->getptr());
BX_INFO(("restoring '%s'", config));
return (read_rc(config) >= 0);
}
bx_bool bx_real_sim_c::restore_logopts()
{
char logopts[BX_PATHNAME_LEN];
char line[512], string[512], devname[20];
char *ret, *ptr;
int i, j, p, dev = 0, type = 0, action = 0;
FILE *fp;
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) {
p = 0;
while (isspace(ptr[p])) p++;
strcpy(string, ptr+p);
while (isspace(string[strlen(string)-1])) string[strlen(string)-1] = 0;
if (i == 0) {
strcpy(devname, string);
dev = get_logfn_id(devname);
} 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;
}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h --- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200 +++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100 @@ -2,7 +2,7 @@ // $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2015 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -276,8 +276,9 @@ void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); - void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status); - void ask (int level, const char *prefix, const char *fmt, va_list ap); + void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status); + void warn(int level, const char *prefix, const char *fmt, va_list ap); + void ask(int level, const char *prefix, const char *fmt, va_list ap); void put(const char *p); void put(const char *n, const char *p); void setio(class iofunctions *); @@ -334,7 +335,8 @@ void set_log_action(int loglevel, int action); const char *getlevel(int i) const; const char *getaction(int i) const; - + int isaction(const char *val) const; + protected: int n_logfn; #define MAX_LOGFNS 512 diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES --- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100 +++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100 @@ -1,5 +1,8 @@ Changes after 2.6.8 release: +- General + - Added new log action "warn", designed to show a message box on error events. + - Configure and compile - Added Android host platform support. diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc --- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200 +++ ./config.cc 2016-12-27 19:53:10.461420368 +0100 @@ -2062,15 +2062,8 @@ actstr = strtok(NULL, ""); if (actstr != NULL) { def_action = !strcmp(module, "action"); - if (!strcmp(actstr, "fatal")) - action = ACT_FATAL; - else if (!strcmp (actstr, "report")) - action = ACT_REPORT; - else if (!strcmp (actstr, "ignore")) - action = ACT_IGNORE; - else if (!strcmp (actstr, "ask")) - action = ACT_ASK; - else { + action = SIM->is_action_name(actstr); + if (action < ACT_IGNORE) { PARSE_ERR(("%s: %s directive malformed.", context, params[0])); free(param); return -1; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc --- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200 +++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100 @@ -2,7 +2,7 @@ // $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2014-2015 The Bochs Project +// Copyright (C) 2014-2016 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 @@ -1478,20 +1478,16 @@ SDL_MessageBoxData msgboxdata; SDL_MessageBoxButtonData buttondata[4]; int level, retcode; -#if BX_DEBUGGER || BX_GDBSTUB - int defbtn = 3; -#else - int defbtn = 2; -#endif char message[512]; level = event->u.logmsg.level; - sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg); + sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); msgboxdata.flags = SDL_MESSAGEBOX_ERROR; msgboxdata.window = window; msgboxdata.title = SIM->get_log_level_name(level); msgboxdata.message = message; - msgboxdata.numbuttons = defbtn + 1; + msgboxdata.numbuttons = 2; msgboxdata.buttons = buttondata; msgboxdata.colorScheme = NULL; buttondata[0].flags = 0; @@ -1500,14 +1496,18 @@ buttondata[1].flags = 0; buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS; buttondata[1].text = "Alwayscont"; + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + msgboxdata.numbuttons = 3; + buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; + buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE; + buttondata[2].text = "Quit"; #if BX_DEBUGGER || BX_GDBSTUB - buttondata[2].flags = 0; - buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; - buttondata[2].text = "Debugger"; -#endif - buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; - buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE; - buttondata[defbtn].text = "Quit"; + msgboxdata.numbuttons = 4; + buttondata[3].flags = 0; + buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG; + buttondata[3].text = "Debugger"; +#endif + } if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) { return -1; } else { diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc --- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100 +++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100 @@ -2,7 +2,7 @@ // $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2015 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -100,6 +100,7 @@ virtual int get_log_action(int mod, int level); virtual void set_log_action(int mod, int level, int action); virtual const char *get_action_name(int action); + virtual int is_action_name(const char *val); virtual int get_default_log_action(int level) { return logfunctions::get_default_action(level); } @@ -123,6 +124,7 @@ 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_warn(const char *prefix, int level, const char *msg); virtual int log_ask(const char *prefix, int level, const char *msg); virtual void log_msg(const char *prefix, int level, const char *msg); virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; } @@ -420,6 +422,11 @@ return io->getaction(action); } +int bx_real_sim_c::is_action_name(const char *val) +{ + return io->isaction(val); +} + const char *bx_real_sim_c::get_log_level_name(int level) { return io->getlevel(level); @@ -575,6 +582,21 @@ } } +int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg) +{ + BxEvent be; + be.type = BX_SYNC_EVT_LOG_ASK; + be.u.logmsg.prefix = prefix; + be.u.logmsg.level = level; + be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN; + // default return value in case something goes wrong. + be.retcode = BX_LOG_NOTIFY_FAILED; + // calling notify + sim_to_ci_event(&be); + return be.retcode; +} + // returns 0 for continue, 1 for alwayscontinue, 2 for die. int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg) { @@ -583,6 +605,7 @@ be.u.logmsg.prefix = prefix; be.u.logmsg.level = level; be.u.logmsg.msg = msg; + be.u.logmsg.flag = BX_LOG_ASK_ASKDLG; // default return value in case something goes wrong. be.retcode = BX_LOG_NOTIFY_FAILED; // calling notify @@ -1157,16 +1180,10 @@ } else if (!strncmp(string, "PANIC=", 6)) { type = LOGLEV_PANIC; } - 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; + action = is_action_name(string+j); + if (action >= ACT_IGNORE) { + set_log_action(dev, type, action); } - set_log_action(dev, type, action); } else { if (i == 1) { BX_ERROR(("restore_logopts(): log module '%s' not found", devname)); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h --- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200 +++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100 @@ -168,6 +168,7 @@ typedef enum { ACT_IGNORE = 0, ACT_REPORT, + ACT_WARN, ACT_ASK, ACT_FATAL, N_ACT @@ -178,11 +179,11 @@ // normally all action choices are available for all event types. The exclude // expression allows some choices to be eliminated if they don't make any // sense. For example, it would be stupid to ignore a panic. -#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ - /* can't die or ask, on debug or info events */ \ - (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \ - /* can't ignore panics */ \ - || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ +#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \ + /* can't die, ask or warn, on debug or info events */ \ + (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \ + /* can't ignore panics */ \ + || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \ ) // floppy / cdrom media status @@ -392,6 +393,7 @@ // synchronizing threads, etc. for each. typedef struct { Bit8u level; + Bit8u flag; const char *prefix; const char *msg; } BxLogMsgEvent; @@ -419,6 +421,12 @@ BX_LOG_NOTIFY_FAILED }; +enum { + BX_LOG_ASK_ASKDLG, + BX_LOG_ASK_MSGBOX_WARN, + BX_LOG_ASK_MSGBOX_QUIT +}; + // Event type: BX_SYNC_EVT_GET_DBG_COMMAND // // This is a synchronous event sent from the simulator to the debugger @@ -675,6 +683,7 @@ virtual int get_default_log_action(int level) {return -1;} virtual void set_default_log_action(int level, int action) {} virtual const char *get_action_name(int action) {return NULL;} + virtual int is_action_name(const char *val) {return -1;} virtual const char *get_log_level_name(int level) {return NULL;} virtual int get_max_log_level() {return -1;} @@ -715,6 +724,9 @@ // send an event from the simulator to the CI. virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;} + // called from simulator when it hits errors, to warn the user + // before continuing simulation + virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;} // called from simulator when it hits serious errors, to ask if the user // wants to continue or not virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;} diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc --- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100 +++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100 @@ -2,7 +2,7 @@ // $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2013 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -552,8 +552,8 @@ } static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] "; -static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" }; -static int log_level_n_choices_normal = 4; +static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" }; +static int log_level_n_choices_normal = N_ACT; void bx_log_options(int individual) { @@ -589,7 +589,7 @@ bx_print_log_action_table(); for (int level=0; level<SIM->get_max_log_level(); level++) { char prompt[1024]; - int action, default_action = 4; // default to no change + int action, default_action = N_ACT; // default to no change sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level)); // do show the no change choice (choices=4) if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0) @@ -718,47 +718,50 @@ event->retcode = event->u.param.param->text_ask(stdin, stderr); return event; case BX_SYNC_EVT_LOG_ASK: - { - int level = event->u.logmsg.level; - fprintf(stderr, "========================================================================\n"); - fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); - fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); - fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); - fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); - fprintf(stderr, " cont - continue execution\n"); - fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); - fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); - fprintf(stderr, " die - stop execution now\n"); - fprintf(stderr, " abort - dump core %s\n", - BX_HAVE_ABORT ? "" : "(Disabled)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + int level = event->u.logmsg.level; + fprintf(stderr, "========================================================================\n"); + fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level)); + fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix); + fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg); + fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level)); + fprintf(stderr, " cont - continue execution\n"); + fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n"); + fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix); + fprintf(stderr, " die - stop execution now\n"); + fprintf(stderr, " abort - dump core %s\n", + BX_HAVE_ABORT ? "" : "(Disabled)"); #if BX_DEBUGGER - fprintf(stderr, " debug - continue and return to bochs debugger\n"); + fprintf(stderr, " debug - continue and return to bochs debugger\n"); #endif #if BX_GDBSTUB - fprintf(stderr, " debug - hand control to gdb\n"); + fprintf(stderr, " debug - hand control to gdb\n"); #endif - int choice; + int choice; ask: - if (ask_menu("Choose one of the actions above: [%s] ", "", - log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) - event->retcode = -1; - // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. - if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; - fflush(stdout); - fflush(stderr); - event->retcode = choice; - } - return event; - case BX_ASYNC_EVT_REFRESH: - case BX_ASYNC_EVT_DBG_MSG: - case BX_ASYNC_EVT_LOG_MSG: - // The text mode interface does not use these events, so just ignore - // them. - return event; - default: - fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); - return event; + if (ask_menu("Choose one of the actions above: [%s] ", "", + log_action_n_choices, log_action_ask_choices, 2, &choice) < 0) + event->retcode = -1; + // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug. + if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask; + fflush(stdout); + fflush(stderr); + event->retcode = choice; + } else { + // warning prompt not implemented + event->retcode = 0; + } + return event; + case BX_ASYNC_EVT_REFRESH: + case BX_ASYNC_EVT_DBG_MSG: + case BX_ASYNC_EVT_LOG_MSG: + // The text mode interface does not use these events, so just ignore + // them. + return event; + default: + fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type); + return event; } assert(0); // switch statement should return } diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc --- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200 +++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100 @@ -2,7 +2,7 @@ // $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2003-2014 The Bochs Project +// Copyright (C) 2003-2016 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 @@ -27,7 +27,7 @@ #include "win32res.h" #include "win32paramdlg.h" -const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"}; +const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"}; HWND GetBochsWindow() { @@ -97,12 +97,16 @@ SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue"); SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)"); #if BX_DEBUGGER - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger"); #endif - SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0); + } else { + SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0); + } SetFocus(GetDlgItem(hDlg, IDASKLIST)); return FALSE; case WM_CLOSE: diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc --- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100 +++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -208,7 +208,6 @@ : wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3}; static wxString names[] = ADVLOG_OPTS_TYPE_NAMES; SetTitle(ADVLOG_OPTS_TITLE); vertSizer = new wxBoxSizer(wxVERTICAL); @@ -1563,7 +1562,7 @@ bool includeNoChange) { static wxString choices[] = LOG_OPTS_CHOICES; - static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4}; + static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5}; wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize); int lastChoice = 0; // remember index of last choice int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h --- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100 +++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100 @@ -2,7 +2,7 @@ // $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $ //////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -354,10 +354,10 @@ #define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?") #define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") } #define LOG_OPTS_N_TYPES 4 -#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") } -#define LOG_OPTS_N_CHOICES_NORMAL 4 -#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change" -#define LOG_OPTS_NO_CHANGE 4 // index of "no change" +#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") } +#define LOG_OPTS_N_CHOICES_NORMAL 5 +#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change" +#define LOG_OPTS_NO_CHANGE 5 // index of "no change" #define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".") wxFlexGridSizer *gridSizer; wxChoice *action[LOG_OPTS_N_TYPES]; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc --- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100 +++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100 @@ -2,7 +2,7 @@ // $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $ ///////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2014 The Bochs Project +// Copyright (C) 2002-2016 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 @@ -1158,6 +1158,10 @@ #if !BX_DEBUGGER && !BX_GDBSTUB dlg.EnableButton(dlg.DEBUG, FALSE); #endif + if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) { + dlg.EnableButton(dlg.DIE, FALSE); + dlg.EnableButton(dlg.DUMP, FALSE); + } dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8)); dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8)); int n = dlg.ShowModal(); diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc --- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100 +++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100 @@ -2687,11 +2687,7 @@ } else { size_x = 30 + maxlen * 6; } - if (lines < 3) { - size_y = 90; - } else { - size_y = 60 + lines * 15; - } + size_y = 70 + lines * 15; x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y, (mode == XDLG_SIMPLE) ? 1 : 2); ypos = 34; @@ -2729,11 +2725,21 @@ bx_param_string_c *sparam; bx_param_enum_c *eparam; bx_list_c *list; + char message[256]; switch (event->type) { case BX_SYNC_EVT_LOG_ASK: - event->retcode = x11_ask_dialog(event); + if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) { + event->retcode = x11_ask_dialog(event); + } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) { + const char *title = SIM->get_log_level_name(event->u.logmsg.level); + sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix, + event->u.logmsg.msg); + bx_param_bool_c bparam(NULL, "warn", title, message, 1); + x11_message_box(&bparam, XDLG_SIMPLE); + event->retcode = 0; + } return event; case BX_SYNC_EVT_ASK_PARAM: param = event->u.param.param; diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc --- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200 +++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100 @@ -2,7 +2,7 @@ // $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2014 The Bochs Project +// Copyright (C) 2001-2016 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 @@ -50,11 +50,25 @@ else return "?"; } +static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" }; + const char* iofunctions::getaction(int i) const { - static const char *name[] = { "ignore", "report", "ask", "fatal" }; assert (i>=ACT_IGNORE && i<N_ACT); - return name[i]; + return act_name[i]; +} + +int iofunctions::isaction(const char *val) const +{ + int action = -1; + + for (int i = 0; i < N_ACT; i++) { + if (!strcmp(val, act_name[i])) { + action = ACT_IGNORE + i; + break; + } + } + return action; } void iofunctions::flush(void) @@ -414,6 +428,11 @@ logio->out(LOGLEV_ERROR, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_ERROR] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_ERROR, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_ERROR] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_ERROR, prefix, fmt, ap); @@ -438,6 +457,11 @@ logio->out(LOGLEV_PANIC, prefix, fmt, ap); va_end(ap); + if (onoff[LOGLEV_PANIC] == ACT_WARN) { + va_start(ap, fmt); + warn(LOGLEV_PANIC, prefix, fmt, ap); + va_end(ap); + } if (onoff[LOGLEV_PANIC] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_PANIC, prefix, fmt, ap); @@ -465,6 +489,36 @@ // the actions ask() and fatal() are not supported here } +void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap) +{ + // Guard against reentry on warn() function. The danger is that some + // function that's called within warn() could trigger another + // BX_ERROR that could call warn() again, leading to infinite + // recursion and infinite asks. + static char in_warn_already = 0; + char buf1[1024]; + if (in_warn_already) { + fprintf(stderr, "logfunctions::warn() should not reenter!!\n"); + return; + } + in_warn_already = 1; + vsnprintf(buf1, sizeof(buf1), fmt, ap); + // FIXME: facility set to 0 because it's unknown. + + // update vga screen. This is useful because sometimes useful messages + // are printed on the screen just before a panic. It's also potentially + // dangerous if this function calls ask again... That's why I added + // the reentry check above. + SIM->refresh_vga(); + + // ensure the text screen is showing + SIM->set_display_mode(DISP_MODE_CONFIG); + SIM->log_warn(prefix, level, buf1); + // return to simulation mode + SIM->set_display_mode(DISP_MODE_SIM); + in_warn_already = 0; +} + void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap) { // Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
action = is_action_name(string+j);
if (action >= ACT_IGNORE) {
set_log_action(dev, type, action);
}
} else {
if (i == 1) {
BX_ERROR(("restore_logopts(): log module '%s' not found", devname));
}
}
i++;
ptr = strtok(NULL, ",");
}
}
} while (!feof(fp));
fclose(fp);
} else {
return 0;
}
return 1;
}
static int bx_restore_getline(FILE *fp, char *line, int maxlen)
{
char *ret = fgets(line, maxlen - 1, fp);
line[maxlen - 1] = '\0';
int len = strlen(line);
if ((len > 0) && (line[len - 1] < ' '))
line[len - 1] = '\0';
return (ret != NULL) ? len : 0;
}
bx_bool bx_real_sim_c::restore_bochs_param(bx_list_c *root, const char *sr_path, const char *restore_name)
{
char devstate[BX_PATHNAME_LEN], devdata[BX_PATHNAME_LEN];
2019-11-23 18:15:50 +03:00
char line[512], buf[512];
char pname[81]; // take extra 81st character for /0
char *ptr;
int i;
unsigned n;
bx_param_c *param = NULL;
FILE *fp, *fp2;
if (root->get_by_name(restore_name) == NULL) {
BX_ERROR(("restore_bochs_param(): unknown parameter to restore"));
return 0;
}
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 {
int len = bx_restore_getline(fp, line, BX_PATHNAME_LEN);
i = 0;
if (len > 0) {
ptr = strtok(line, " ");
while (ptr) {
if (i == 0) {
if (!strcmp(ptr, "}")) {
base->restore();
base = (bx_list_c*)base->get_parent();
break;
} else {
param = get_param(ptr, base);
strncpy(pname, ptr, 80);
}
} else if (i == 2) {
if (param == NULL) {
BX_PANIC(("cannot find param '%s'!", pname));
}
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:
case BXT_PARAM_BOOL:
case BXT_PARAM_ENUM:
case BXT_PARAM_STRING:
case BXT_PARAM_BYTESTRING:
param->parse_param(ptr);
break;
case BXT_PARAM_DATA:
{
bx_shadow_data_c *dparam = (bx_shadow_data_c*)param;
if (!dparam->is_text_format()) {
sprintf(devdata, "%s/%s", sr_path, ptr);
fp2 = fopen(devdata, "rb");
if (fp2 != NULL) {
fread(dparam->getptr(), 1, dparam->get_size(), fp2);
fclose(fp2);
}
} else if (!strcmp(ptr, "[")) {
i = 0;
do {
bx_restore_getline(fp, buf, BX_PATHNAME_LEN);
ptr = strtok(buf, " ");
while (ptr) {
if (!strcmp(ptr, "]")) {
i = 0;
break;
} else {
if (sscanf(ptr, "0x%02x", &n) == 1) {
dparam->set(i++, (Bit8u)n);
}
}
ptr = strtok(NULL, " ");
}
} while (i > 0);
}
}
break;
case BXT_PARAM_FILEDATA:
sprintf(devdata, "%s/%s", sr_path, ptr);
fp2 = fopen(devdata, "rb");
if (fp2 != NULL) {
FILE **fpp = ((bx_shadow_filedata_c*)param)->get_fpp();
// If the temporary backing store file wasn't created, do it now.
if (*fpp == NULL)
*fpp = tmpfile();
if (*fpp != NULL) {
while (!feof(fp2)) {
char buffer[64];
size_t chars = fread(buffer, 1, sizeof(buffer), fp2);
fwrite(buffer, 1, chars, *fpp);
}
fflush(*fpp);
}
((bx_shadow_filedata_c*)param)->restore(fp2);
fclose(fp2);
}
break;
case BXT_LIST:
base = (bx_list_c*)param;
break;
default:
BX_ERROR(("restore_bochs_param(): unknown parameter type"));
}
}
}
i++;
ptr = strtok(NULL, " ");
}
}
} while (!feof(fp));
fclose(fp);
} else {
BX_ERROR(("restore_bochs_param(): error in file open"));
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++) {
if (!restore_bochs_param(sr_list, get_param_string(BXPN_RESTORE_PATH)->getptr(), sr_list->get(dev)->get_name()))
return 0;
}
return 1;
}
bx_bool bx_real_sim_c::save_sr_param(FILE *fp, bx_param_c *node, const char *sr_path, int level)
{
int i, j;
2020-08-06 23:21:14 +03:00
char pname[BX_PATHNAME_LEN], tmpstr[BX_PATHNAME_LEN+1];
FILE *fp2;
for (i=0; i<level; i++)
fprintf(fp, " ");
if (node == NULL) {
BX_ERROR(("NULL pointer"));
return 0;
}
fprintf(fp, "%s = ", node->get_name());
switch (node->get_type()) {
case BXT_PARAM_NUM:
case BXT_PARAM_BOOL:
case BXT_PARAM_ENUM:
case BXT_PARAM_STRING:
case BXT_PARAM_BYTESTRING:
node->dump_param(fp);
fprintf(fp, "\n");
break;
case BXT_PARAM_DATA:
{
bx_shadow_data_c *dparam = (bx_shadow_data_c*)node;
if (!dparam->is_text_format()) {
node->get_param_path(pname, BX_PATHNAME_LEN);
if (!strncmp(pname, "bochs.", 6)) {
strcpy(pname, pname+6);
}
fprintf(fp, "%s\n", pname);
if (sr_path)
sprintf(tmpstr, "%s/%s", sr_path, pname);
else
strcpy(tmpstr, pname);
fp2 = fopen(tmpstr, "wb");
if (fp2 != NULL) {
fwrite(dparam->getptr(), 1, dparam->get_size(), fp2);
fclose(fp2);
}
} else {
fprintf(fp, "[\n");
for (i=0; i < (int)dparam->get_size(); i++) {
if ((i % 16) == 0) {
for (j=0; j<(level+1); j++)
fprintf(fp, " ");
} else {
fprintf(fp, ", ");
}
fprintf(fp, "0x%02x", dparam->get(i));
if (i == (int)(dparam->get_size() - 1)) {
fprintf(fp, "\n");
} else if ((i % 16) == 15) {
fprintf(fp, ",\n");
}
}
for (i=0; i<level; i++)
fprintf(fp, " ");
fprintf(fp, "]\n");
}
}
break;
case BXT_PARAM_FILEDATA:
fprintf(fp, "%s.%s\n", node->get_parent()->get_name(), node->get_name());
if (sr_path)
sprintf(tmpstr, "%s/%s.%s", sr_path, node->get_parent()->get_name(), node->get_name());
else
sprintf(tmpstr, "%s.%s", node->get_parent()->get_name(), node->get_name());
fp2 = fopen(tmpstr, "wb");
if (fp2 != NULL) {
FILE **fpp = ((bx_shadow_filedata_c*)node)->get_fpp();
// If the backing store hasn't been created, just save an empty 0 byte placeholder file.
if (*fpp != NULL) {
while (!feof(*fpp)) {
char buffer[64];
size_t chars = fread (buffer, 1, sizeof(buffer), *fpp);
fwrite(buffer, 1, chars, fp2);
}
fflush(*fpp);
}
((bx_shadow_filedata_c*)node)->save(fp2);
fclose(fp2);
}
break;
case BXT_LIST:
{
fprintf(fp, "{\n");
bx_list_c *list = (bx_list_c*)node;
for (i=0; i < list->get_size(); i++) {
save_sr_param(fp, list->get(i), sr_path, level+1);
}
for (i=0; i<level; i++)
fprintf(fp, " ");
fprintf(fp, "}\n");
break;
}
default:
BX_ERROR(("save_sr_param(): unknown parameter type"));
return 0;
}
return 1;
}
bx_bool bx_real_sim_c::opt_plugin_ctrl(const char *plugname, bx_bool load)
{
bx_list_c *plugin_ctrl = (bx_list_c*)SIM->get_param(BXPN_PLUGIN_CTRL);
if (!strcmp(plugname, "*")) {
// verify optional plugin configuration and load/unload plugins if necessary
int i = 0;
while (i < plugin_ctrl->get_size()) {
bx_param_bool_c *plugin = (bx_param_bool_c*)plugin_ctrl->get(i);
if (load == (bx_bool)plugin->get()) {
opt_plugin_ctrl(plugin->get_name(), load);
if (load) i++;
} else {
i++;
}
}
return 1;
}
if (load != PLUG_device_present(plugname)) {
if (load) {
if (PLUG_load_opt_plugin(plugname)) {
if (plugin_ctrl->get_by_name(plugname) == NULL) {
new bx_param_bool_c(plugin_ctrl, plugname, "", "", 1);
}
return 1;
} else {
BX_PANIC(("optional plugin '%s' not found", plugname));
return 0;
}
} else {
PLUG_unload_opt_plugin(plugname);
plugin_ctrl->remove(plugname);
return 1;
}
} else if (!load && !PLUG_device_present(plugname)) {
plugin_ctrl->remove(plugname);
}
return 0;
}
void bx_real_sim_c::init_std_nic_options(const char *name, bx_list_c *menu)
{
bx_init_std_nic_options(name, menu);
}
void bx_real_sim_c::init_usb_options(const char *usb_name, const char *pname, int maxports)
{
bx_init_usb_options(usb_name, pname, maxports);
}
int bx_real_sim_c::parse_param_from_list(const char *context, const char *param, bx_list_c *base)
{
return bx_parse_param_from_list(context, param, base);
}
int bx_real_sim_c::parse_nic_params(const char *context, const char *param, bx_list_c *base)
{
return bx_parse_nic_params(context, param, base);
}
int bx_real_sim_c::parse_usb_port_params(const char *context, bx_bool devopt,
const char *param, int maxports, bx_list_c *base)
{
return bx_parse_usb_port_params(context, devopt, param, maxports, base);
}
int bx_real_sim_c::split_option_list(const char *msg, const char *rawopt,
char **argv, int max_argv)
{
return bx_split_option_list(msg, rawopt, argv, max_argv);
}
int bx_real_sim_c::write_param_list(FILE *fp, bx_list_c *base, const char *optname, bx_bool multiline)
{
return bx_write_param_list(fp, base, optname, multiline);
}
int bx_real_sim_c::write_usb_options(FILE *fp, int maxports, bx_list_c *base)
{
return bx_write_usb_options(fp, maxports, base);
}
#if BX_USE_GUI_CONSOLE
int bx_real_sim_c::bx_printf(const char *fmt, ...)
{
va_list ap;
char buf[1025];
va_start(ap, fmt);
vsnprintf(buf, 1024, fmt, ap);
va_end(ap);
if (get_init_done()) {
if (bx_gui->has_gui_console()) {
return bx_gui->bx_printf(buf);
}
}
return printf("%s", buf);
}
char* bx_real_sim_c::bx_gets(char *s, int size, FILE *stream)
{
if (get_init_done()) {
if (bx_gui->has_gui_console()) {
return bx_gui->bx_gets(s, size);
}
}
return fgets(s, size, stream);
}
#endif