Commit Graph

315 Commits

Author SHA1 Message Date
Volker Ruppert
b61b9d255a Moved all Bochs multi-threading definitions from bochs.h and osdep.h to a new
file called "bxthread.h".
2017-09-10 15:55:13 +00:00
Volker Ruppert
c160fd4830 Bochs thread handling improvements:
- Modified win32 thread macros to use the handle instead of the id.
- Added new macro BX_THREAD_KILL to terminate threads.
Voodoo thread changes:
- Let the cmdfifo_thread sleep while the CMDFIFO is disabled.
- Kill the cmdfifo_thread in destructor and removed old thread control code.
2017-05-18 18:34:00 +00:00
Volker Ruppert
4ebe5e6879 If setenv() is present on Windows and variable BXSHARE is not set, use the
function get_builtin_variable() to set it up with either the value of the Bochs
registry key or the BX_SHARE_PATH constant.
2017-04-22 10:17:54 +00:00
Stanislav Shwartsman
68b9d10b76 reverting latest commit, merged by mistake 2017-04-20 18:31:52 +00:00
Stanislav Shwartsman
e3fdf42225 use std::string in param_tree and gain more robust code with automatic garbage collection 2017-04-20 18:26:45 +00:00
Volker Ruppert
400704d038 Added macro BX_FATAL() that works like BX_PANIC(), but with hardcoded action
"fatal". It can be used for all cases when there is no workaroud present to
avoid application crash or incorrect simulation behaviour. As a first step now
using BX_FATAL() for some data structure size and bit field errors.
2016-12-30 10:04:06 +00:00
Volker Ruppert
7eee83a1d9 Some work on the logio code.
- Show message box (modified ask dialog) in method fatal() if not called after
  ask dialog or pressing power button.
- Removed code for unsupported actions "ask" and "fatal" from info() method.
- Some related small code cleanups.
2016-12-29 17:22:46 +00:00
Volker Ruppert
85fcabbd8f 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 15:06:34 +00:00
Volker Ruppert
cd68194269 Added Android host platform support to Bochs based on SF patch #534.
- added Android case to the configure script.
- renamed file memory.h to memory-bochs.h to fix conflict with NDK.
- fixed Android issues in some files.
2016-08-12 17:06:14 +00:00
Volker Ruppert
be304bf4af Definition of maximum nuber of USB ports moved from bochs.h to device. 2015-10-31 15:12:36 +00:00
Volker Ruppert
fd690a3a31 Fixed compilation errors found on Cygwin64
- The 'Bits' type used in the opl files is incompatible with Bit64s. Modified
  typedef to fix this issue.
- On Windows use Sleep() directly, since msleep() doesn't exist in Cygwin.
2015-05-05 18:06:05 +00:00
Stanislav Shwartsman
e16c6eb30c preparations and interface definition for memory type support 2015-02-19 20:23:08 +00:00
Volker Ruppert
3dca0bd8cf Some work in the soundmod beep code and multithreading improvements.
- Beep thread now only started one per simulation.
- Added some more multithreading macros and use them in rfb, vncsrv and soundmod.
- TODO: implement mixer thread and remove beep thread.
2015-01-17 19:53:03 +00:00
Volker Ruppert
0c205fce26 Some work in the lowlevel sound code.
- Added framework for polling wave data and use it for beep output in sdl.
- Some work in the beep thread code (to be continued).
- Moved macros required for multithreading to bochs.h.
2015-01-04 21:12:41 +00:00
Volker Ruppert
7330f3a61c Changed to way to determine the default lowlevel sound driver (part of the
mixing3.patch by Dawn Teschendorf).
2014-11-22 11:43:40 +00:00
Stanislav Shwartsman
1924780b06 added ability to dump Bochs param tree in XML format 2014-11-15 22:03:52 +00:00
Stanislav Shwartsman
8d1e3b2ac1 Added statistics collection infrastructure in Bochs and
implemented important CPU statistics which were used for Bochs CPU model performance analysis.
old statistics code from paging.cc and cpu.cc is replaced with new infrastructure.

In order to enale statitics collection in Bochs CPU:

- Enable statistics @ compilation time in cpu/cpustats.h
- Dump statistics periodically by adding -dumpstats N into Bochs command line
2014-10-14 15:59:10 +00:00
Volker Ruppert
cf93269380 Define WIN32_LEAN_AND_MEAN to make using Winsock2 possible (for vncsrv and slirp).
TODO: change include statements to winsock2.h and link with ws2_32.dll.
2014-02-15 00:23:36 +00:00
Volker Ruppert
fc4538a131 Some fixes / improvements in logging system
- fixed pluginlog init in non-plugin mode
- reduced logprefix length limit and use it for the related string parameter
- increase the device prefix size to 6
- TODO: change some more device prefixes
2013-12-29 10:41:11 +00:00
Volker Ruppert
b9944b43b5 Some small fixes
- bochs.h:     fixed gcc 4.8 warning
- config.h.in: fixed newline
- extplugin.h: fixed VS2008Ex plugins compilation
- gui.cc:      fixed tooltip
2013-11-07 19:38:23 +00:00
Volker Ruppert
800da0f390 some fixes for Bochs on MorphOS (based on a patch by Thore Sittly)
- byte-swapping stuff fixed
- TODO: gui fixes in the amigaos.cc code
2013-05-24 17:58:49 +00:00
Stanislav Shwartsman
66c9274bdb max physical addr size is 48 bit so print less characters 2013-02-12 21:26:23 +00:00
Volker Ruppert
2daadfcd85 parse serial, parallel and sound bochsrc options using the parameter list
- fixed small bug in the ne2k parser code
- added warnings to the new parser code
2013-01-26 18:17:23 +00:00
Volker Ruppert
34dbbe1c74 save the mouse, serial, parallel and ata resource options using the parameter tree 2013-01-19 22:37:15 +00:00
Volker Ruppert
a5e5ac69b0 save the network configuration lines using the parameter tree
- fixed bochsrc line after a "raw byte" string parameter
- changed parameter name "macaddr" to "mac" (same as bochsrc option parameter)
- skip disabled parameters when building the bochsrc line
- added "multiline" switch to select the output format (one or multiple lines)
- renamed siminterface method and use it in the network devices code
2013-01-19 12:25:53 +00:00
Volker Ruppert
daf92361fe save cpuid bochsrc line using the parameter list directly
TODO #1: use bx_write_param_list() for other Bochs feature settings
TODO #2: use the parameter list in the bochsrc parser
2013-01-18 17:11:23 +00:00
Volker Ruppert
c8012c3f1d cleaned up devices timer handler / fixed keyboard paste counter 2012-10-30 17:25:33 +00:00
Volker Ruppert
d0a545c010 - moved log action definitions to siminterface.h
- wxdialog: use symbols and allow log action ACT_IGNORE for LOGLEV_ERROR
- wxdialog: removed obsolete pass event
- TODO: fix win32dialog stuff in a similar way
2012-10-05 16:04:40 +00:00
Stanislav Shwartsman
49bb3ba8f5 some cleanups and optimizations with new event interface 2012-10-03 15:49:45 +00:00
Volker Ruppert
c2f9150497 - split "show ips" handler from bx_signal_handler to simplify usage without alarm() 2012-08-26 12:32:10 +00:00
Stanislav Shwartsman
515d8b5c25 add new instrumentation callbacks for physical memory access from CPU 2012-06-18 11:41:26 +00:00
Volker Ruppert
70a38a8a3d - apply 'log actions by device' to the existing modules before editing them
in the config interface. Applied settings are marked as 'done' with the value
  -1 to avoid unwanted modification. NOTE: Not all Bochs modules exist when
  running the start menu / dialog.
2012-04-06 13:15:27 +00:00
Stanislav Shwartsman
fa03e8b925 added const to several class members 2012-03-27 21:30:34 +00:00
Stanislav Shwartsman
9461797886 added extra param to debugger phy access callback + cleanup in vmexit functions 2012-01-17 21:50:15 +00:00
Stanislav Shwartsman
039326d0c9 always return const pointer from functions - these strings are not planned to be modified 2012-01-11 19:57:38 +00:00
Volker Ruppert
c403b4b699 - devices 'usb_ohci' and 'usb_uhci': moved config parameter creation and bochsrc
option parsing to the plugin device code
- added function bx_init_usb_options() to reduce code duplication
- added log function names for 'usb_ohci' and 'usb_uhci'
- documentation updates
2012-01-08 12:43:46 +00:00
Volker Ruppert
a48ef5f719 - added check for bochsrc options of optional plugins that have been moved to
the device code. Added panic message to force the user to enable the plugin
  with 'plugin_ctrl'.
- moved config parameter creation and bochsrc option parsing for device
  'usb_xhci' to the plugin device code
- added minimal documentation for the "log action per device" feature
- added log function name for 'usb_xhci'
2012-01-07 14:14:53 +00:00
Volker Ruppert
b130bf671b - initial "log action by device" implementation added (TODO: check for
invalid module names, save log actions to bochsrc)
- added new member 'name' to the logfunctions class for the case the prefix
  is too short. Added to some devices with longer names.
2011-12-29 19:51:54 +00:00
Stanislav Shwartsman
644c7c6289 undo bxswap change - it breaks build with bx_debugger enabled. error - multiple definition of bx_swap16 in parser.o and lexer.o 2011-12-28 22:43:18 +00:00
Stanislav Shwartsman
c62426145a moved bx_bswap definition into osdep.h so bximage tool can also include them 2011-12-28 22:17:12 +00:00
Stanislav Shwartsman
bfcbb81602 SVM:
- IO intercept is not implemented yet
 - MSR intercept is not implemented yet

VMX:
 Fixed Bochs PANIC crash when doing I/O access crossing VMX I/O permission bitmaps.
 This can happen because access_physical_read and access_physical_write cannot access memory cross 4K boundary.
2011-12-25 22:09:31 +00:00
Volker Ruppert
aad2d89c83 - rewrite of the optional plugin control feature. Now the plugins are loaded
directly while parsing the bochsrc or command line. If plugin support is enabled,
  the option could load all optional plugins, not only the ones supported before.
  NOTE #1: The old option had all plugins enabled by default and gave the user
           a chance to diable them. Now the plugins are only loaded if they
           appear in the config line and they are set to "1".
  NOTE #2: Loading a plugin that is controlled by a bochsrc option is possible,
           but it currently leads to a panic, since the load command is still
           present in devices.cc.
  NOTE #3: The plugin init code creates the device object and registers the
           optional plugin device. As an option, it can create config parameters
           and register an option parser. The device init, register state and
           reset is still handled in devices.cc, but in the order the devices
           have been loaded with the plugin control.
  NOTE #4: If plugin support is disabled, the plugin control only accepts the
           devices listed in plugin.cc.
- plugin init of core plugins now fails if they are not loaded with the expected
  type. For core plugins the load order is important and they cannot be handled
  with the chained devices list (used for optional and user plugins).
- some additions for calling config.cc functions from a plugin device
2011-12-25 08:52:34 +00:00
Stanislav Shwartsman
b16d71175d Fixed 'show off' command in internal debugger
Removed not working record/playback obsolete commands from internal debugger
2011-10-09 19:26:30 +00:00
Stanislav Shwartsman
c67338203c small fixups, code cleanup and reorganization 2011-09-05 17:14:49 +00:00
Stanislav Shwartsman
e61da281c0 update cpu-configurable doc 2011-08-31 16:33:12 +00:00
Volker Ruppert
4b4f691a80 - don't include plugin.h in bochs.h to reduce dependencies 2011-08-17 22:41:03 +00:00
Stanislav Shwartsman
a03e0266fb added yonah CPUID to cpudb. remove bxversion.h from dep files 2011-08-16 19:58:56 +00:00
Volker Ruppert
c35e385139 - removed 'text_snapshot_check' feature and related BX_PASS loglevel
- documentation updates
2011-07-31 14:38:03 +00:00
Stanislav Shwartsman
432bf97197 was playing with SMP and debugger 2011-07-09 22:17:16 +00:00
Volker Ruppert
c2d0c207f7 - preparing Bochs for experimental USB xHCI support (written by Ben Lunt) TODO list:
- add sources (update in progress)
  - update configure script
  - initialize new USB devices member 'max_packet_size' (need help from Ben)
2011-07-04 19:42:47 +00:00