Example #1
0
void logfunctions::fatal(const char *prefix, const char *fmt, va_list ap, int exit_status)
{
#if !BX_WITH_WX
  // store prefix and message in 'exit_msg' before unloading device plugins
  char tmpbuf[1024];
  char exit_msg[1024];

  vsprintf(tmpbuf, fmt, ap);
  sprintf(exit_msg, "%s %s", prefix, tmpbuf);
#endif
#if !BX_DEBUGGER
  bx_atexit();
#endif
#if BX_WITH_CARBON
  if(!isatty(STDIN_FILENO) && !SIM->get_init_done())
  {
    char buf1[1024];
    char buf2[1024];
    vsnprintf(buf1, sizeof(buf1), fmt, ap);
    snprintf(buf2, sizeof(buf2), "Bochs startup error\n%s", buf1);
    carbonFatalDialog(buf2,
      "For more information, try running Bochs within Terminal by clicking on \"bochs.scpt\".");
  }
#endif
#if !BX_WITH_WX
  static const char *divider = "========================================================================";
  fprintf(stderr, "%s\n", divider);
  fprintf(stderr, "Bochs is exiting with the following message:\n");
  fprintf(stderr, "%s", exit_msg);
  fprintf(stderr, "\n%s\n", divider);
#endif
#if !BX_DEBUGGER
  BX_EXIT(exit_status);
#else
  static bx_bool dbg_exit_called = 0;
  if (dbg_exit_called == 0) {
    dbg_exit_called = 1;
    bx_dbg_exit(exit_status);
  }
#endif
  // not safe to use BX_* log functions in here.
  fprintf(stderr, "fatal() should never return, but it just did\n");
}
Example #2
0
int bx_config_interface(int menu)
{
  Bit32u choice;
  char sr_path[CI_PATH_LENGTH];
  while (1) {
    switch (menu) {
      case BX_CI_INIT:
        bx_config_interface_init();
        return 0;
      case BX_CI_START_SIMULATION:
        SIM->begin_simulation(bx_startup_flags.argc, bx_startup_flags.argv);
        // we don't expect it to return, but if it does, quit
        SIM->quit_sim(1);
        break;
      case BX_CI_START_MENU:
        {
          Bit32u n_choices = 7;
          Bit32u default_choice;
          switch (SIM->get_param_enum(BXPN_BOCHS_START)->get()) {
            case BX_LOAD_START:
              default_choice = 2; break;
            case BX_EDIT_START:
              default_choice = 3; break;
            default:
              default_choice = 6; break;
          }
          if (ask_uint(startup_menu_prompt, "", 1, n_choices, default_choice, &choice, 10) < 0) return -1;
          switch (choice) {
            case 1:
              fprintf(stderr, "I reset all options back to their factory defaults.\n\n");
              SIM->reset_all_param();
              SIM->get_param_enum(BXPN_BOCHS_START)->set(BX_EDIT_START);
              break;
            case 2:
              // Before reading a new configuration, reset every option to its
              // original state.
              SIM->reset_all_param();
              if (bx_read_rc(NULL) >= 0)
                SIM->get_param_enum(BXPN_BOCHS_START)->set(BX_RUN_START);
              break;
            case 3:
              bx_config_interface(BX_CI_START_OPTS);
              SIM->get_param_enum(BXPN_BOCHS_START)->set(BX_RUN_START);
              break;
            case 4: bx_write_rc(NULL); break;
            case 5:
              if (ask_string("\nWhat is the path to restore the Bochs state from?\nTo cancel, type 'none'. [%s] ", "none", sr_path) >= 0) {
                if (strcmp(sr_path, "none")) {
                  SIM->get_param_bool(BXPN_RESTORE_FLAG)->set(1);
                  SIM->get_param_string(BXPN_RESTORE_PATH)->set(sr_path);
                  bx_config_interface(BX_CI_START_SIMULATION);
                }
              }
              break;
            case 6: bx_config_interface(BX_CI_START_SIMULATION); break;
            case 7: SIM->quit_sim(1); return -1;
            default: BAD_OPTION(menu, choice);
          }
        }
        break;
      case BX_CI_START_OPTS:
        if (ask_uint(startup_options_prompt, "", 0, 15+BX_PLUGINS, 0, &choice, 10) < 0) return -1;
        switch (choice) {
          case 0: return 0;
          case 2: bx_log_options(0); break;
          case 3: bx_log_options(1); break;
          case 1: do_menu("log"); break;
          case 4: do_menu("cpu"); break;
          case 5: do_menu("cpuid"); break;
          case 6: do_menu("memory"); break;
          case 7: do_menu("clock_cmos"); break;
          case 8: do_menu("pci"); break;
          case 9: do_menu("display"); break;
          case 10: do_menu("keyboard_mouse"); break;
          case 11: do_menu(BXPN_MENU_DISK); break;
          case 12: do_menu("ports"); break;
          case 13: do_menu("network"); break;
          case 14: do_menu("sound"); break;
          case 15: do_menu("misc"); break;
#if BX_PLUGINS
          case 16: do_menu("user"); break;
#endif
          default: BAD_OPTION(menu, choice);
        }
        break;
      case BX_CI_RUNTIME:
        {
          bx_list_c *cdromop = NULL;
          char pname[80];
          char prompt[1024];
          build_runtime_options_prompt(runtime_menu_prompt, prompt, 1024);
          if (ask_uint(prompt, "", 1, BX_CI_RT_QUIT, BX_CI_RT_CONT, &choice, 10) < 0) return -1;
          switch (choice) {
            case BX_CI_RT_FLOPPYA:
              if (SIM->get_param_enum(BXPN_FLOPPYA_DEVTYPE)->get() != BX_FDD_NONE) do_menu(BXPN_FLOPPYA);
              break;
            case BX_CI_RT_FLOPPYB:
              if (SIM->get_param_enum(BXPN_FLOPPYB_DEVTYPE)->get() != BX_FDD_NONE) do_menu(BXPN_FLOPPYB);
              break;
            case BX_CI_RT_CDROM1:
            case BX_CI_RT_CDROM2:
            case BX_CI_RT_CDROM3:
            case BX_CI_RT_CDROM4:
              int device;
              if (SIM->get_cdrom_options(choice - BX_CI_RT_CDROM1, &cdromop, &device) && SIM->get_param_bool("present", cdromop)->get()) {
                cdromop->get_param_path(pname, 80);
                do_menu(pname);
              }
              break;
            case BX_CI_RT_IPS:
              // not implemented yet because I would have to mess with
              // resetting timers and pits and everything on the fly.
              // askparam(BXPN_IPS);
              break;
            case BX_CI_RT_LOGOPTS1: bx_log_options(0); break;
            case BX_CI_RT_LOGOPTS2: bx_log_options(1); break;
            case BX_CI_RT_INST_TR: NOT_IMPLEMENTED(choice); break;
            case BX_CI_RT_USB: do_menu(BXPN_MENU_RUNTIME_USB); break;
            case BX_CI_RT_MISC: do_menu(BXPN_MENU_RUNTIME_MISC); break;
            case BX_CI_RT_CONT:
              SIM->update_runtime_options();
              fprintf(stderr, "Continuing simulation\n");
              return 0;
            case BX_CI_RT_QUIT:
              fprintf(stderr, "You chose quit on the configuration interface.\n");
              bx_user_quit = 1;
#if !BX_DEBUGGER
              bx_atexit();
              SIM->quit_sim(1);
#else
              bx_dbg_exit(1);
#endif
              return -1;
            default: fprintf(stderr, "Menu choice %d not implemented.\n", choice);
          }
        }
        break;
      default:
        fprintf(stderr, "Unknown config interface menu type.\n");
        assert(menu >=0 && menu < BX_CI_N_MENUS);
    }
  }
}