From 81eca54b516664e0d9b5f4729ebd39569d73e247 Mon Sep 17 00:00:00 2001 From: Christophe Bothamy Date: Sat, 9 Nov 2002 14:12:10 +0000 Subject: [PATCH] - fix [ 625696 ] text config menu: default can be wrong. New behaviour is: . No command line arg (user want to load or create a new conf file) -> no .bochsrc is loaded -> defaults to "2. Read options from..." . command line arg -q (user want to quick start from .bochsrc) -> .bochsrc is loaded -> if found Run the simulation -> if not found defaults to "2. Read options from..." . command line arg -f (user want to edit a conf file) -> conf file is loaded -> if found defaults to "3. Edit options" -> if not found defaults to "2. Read options from..." . command line arg -qf (user want to quick start from a conf file) -> conf file is loaded -> if found Run the simulation -> if not found defaults to "2. Read options from..." . After selection of "2. Read options from..." -> defaults to "5. Begin simulation" - fix "enable-control-panel" behaviour in configure.in. - check if a romimage was supplied in the conf file. If not, print a hint about a missing/corrupt conf file. I hope I did not break anything, notably the Carbon gui --- bochs/configure | 9 +++--- bochs/configure.in | 11 ++++---- bochs/gui/siminterface.cc | 4 ++- bochs/gui/siminterface.h | 13 +++++++-- bochs/gui/textconfig.cc | 23 +++++++++++---- bochs/gui/wxmain.cc | 4 +-- bochs/main.cc | 59 +++++++++++++++++++++++++++------------ 7 files changed, 82 insertions(+), 41 deletions(-) diff --git a/bochs/configure b/bochs/configure index 04a6b1ff3..3795cbb0c 100755 --- a/bochs/configure +++ b/bochs/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in,v 1.159 2002/11/01 17:53:47 bdenney Exp . +# From configure.in Id: configure.in,v 1.160 2002/11/08 21:29:16 cbothamy Exp . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. # @@ -17439,7 +17439,7 @@ echo "${ECHO_T}yes" >&6 fi; -# continue to support --enable-control-panel and make it do the same +# continue to support --enable-control-panel and make it do the same, but with no default # as before. echo "$as_me:$LINENO: checking for control panel" >&5 echo $ECHO_N "checking for control panel... $ECHO_C" >&6 @@ -17457,9 +17457,8 @@ echo "${ECHO_T}no" >&6 fi else - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - use_config_interface=1 + echo "$as_me:$LINENO: result: same as config-interface setting" >&5 +echo "${ECHO_T}same as config-interface setting" >&6 fi; diff --git a/bochs/configure.in b/bochs/configure.in index 67143829d..17647a2ff 100644 --- a/bochs/configure.in +++ b/bochs/configure.in @@ -2,7 +2,7 @@ dnl // Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) AC_INIT(bochs.h) -AC_REVISION([[$Id: configure.in,v 1.160 2002-11-08 21:29:16 cbothamy Exp $]]) +AC_REVISION([[$Id: configure.in,v 1.161 2002-11-09 14:12:09 cbothamy Exp $]]) AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(ltdlconf.h) @@ -326,21 +326,20 @@ AC_ARG_ENABLE(config-interface, ] ) -# continue to support --enable-control-panel and make it do the same +# continue to support --enable-control-panel and make it do the same, but with no default # as before. AC_MSG_CHECKING(for control panel) AC_ARG_ENABLE(control-panel, [ --enable-control-panel Deprecated. Use --enable-config-interface.], [if test "$enableval" = yes; then - AC_MSG_RESULT(yes) + AC_MSG_RESULT(yes, overrides config-interface setting) use_config_interface=1 else - AC_MSG_RESULT(no) + AC_MSG_RESULT(no, overrides config-interface setting) use_config_interface=0 fi], [ - AC_MSG_RESULT(yes) - use_config_interface=1 + AC_MSG_RESULT(same as config-interface setting) ] ) diff --git a/bochs/gui/siminterface.cc b/bochs/gui/siminterface.cc index 6d14a9417..07c1f77ab 100644 --- a/bochs/gui/siminterface.cc +++ b/bochs/gui/siminterface.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: siminterface.cc,v 1.82 2002-11-08 13:18:05 vruppert Exp $ +// $Id: siminterface.cc,v 1.83 2002-11-09 14:12:10 cbothamy Exp $ ///////////////////////////////////////////////////////////////////////// // // See siminterface.h for description of the siminterface concept. @@ -396,6 +396,8 @@ bx_real_sim_c::get_cdrom_options (int level, bx_atadevice_options *out, int *whe return 0; } +char *bochs_start_names[] = { "quick", "load", "edit", "run" }; +int n_bochs_start_names = 3; char *floppy_type_names[] = { "none", "1.2M", "1.44M", "2.88M", "720K", "360K", NULL }; int floppy_type_n_sectors[] = { -1, 80*2*15, 80*2*18, 80*2*36, 80*2*9, 40*2*9 }; int n_floppy_type_names = 6; diff --git a/bochs/gui/siminterface.h b/bochs/gui/siminterface.h index ee7afb945..b65d421a4 100644 --- a/bochs/gui/siminterface.h +++ b/bochs/gui/siminterface.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: siminterface.h,v 1.83 2002-11-01 15:19:43 bdenney Exp $ +// $Id: siminterface.h,v 1.84 2002-11-09 14:12:10 cbothamy Exp $ ///////////////////////////////////////////////////////////////////////// // // Before I can describe what this file is for, I have to make the @@ -119,7 +119,7 @@ typedef enum { // list if parameter id values. The actual values are not important; // it's only important that they all be different from each other. typedef enum { - BXP_NULL = 101, + BXP_NULL = 301, BXP_IPS, BXP_REALTIME_PIT, BXP_VGA_UPDATE_INTERVAL, @@ -325,7 +325,7 @@ typedef enum { BXP_KEYBOARD, BXP_USER_SHORTCUT, BXP_ASK_FOR_PATHNAME, // for general file selection dialog - BXP_QUICK_START, // read bochsrc and start simulation immediately + BXP_BOCHS_START, // How Bochs starts // experiment: add params for CPU registers BXP_CPU_PARAMETERS, BXP_CPU_EAX, @@ -1055,6 +1055,11 @@ public: //////////////////////////////////////////////////////////////// +#define BX_QUICK_START 0 // read bochsrc and start simulation immediately +#define BX_LOAD_START 1 // default action load conf file +#define BX_EDIT_START 2 // default action edit conf file +#define BX_RUN_START 3 // default action start execution + #define BX_FLOPPY_NONE 10 // floppy not present #define BX_FLOPPY_1_2 11 // 1.2M 5.25" #define BX_FLOPPY_1_44 12 // 1.44M 3.5" @@ -1079,6 +1084,8 @@ public: #define BX_ATA_TRANSLATION_AUTO 4 #define BX_ATA_TRANSLATION_LAST 4 +extern char *bochs_start_names[]; +extern int n_bochs_start_names; extern char *floppy_type_names[]; extern int floppy_type_n_sectors[]; extern int n_floppy_type_names; diff --git a/bochs/gui/textconfig.cc b/bochs/gui/textconfig.cc index ac5b1e19e..aeb80ce9b 100644 --- a/bochs/gui/textconfig.cc +++ b/bochs/gui/textconfig.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: textconfig.cc,v 1.2 2002-11-01 15:19:47 bdenney Exp $ +// $Id: textconfig.cc,v 1.3 2002-11-09 14:12:10 cbothamy Exp $ ///////////////////////////////////////////////////////////////////////// // // This is code for a text-mode configuration interfac. Note that this file @@ -413,8 +413,16 @@ int bx_config_interface (int menu) } case BX_CI_START_MENU: { - static int read_rc = 0; - Bit32u default_choice = 5; + Bit32u default_choice; + switch (SIM->get_param_enum(BXP_BOCHS_START)->get ()) { + case BX_LOAD_START: + default_choice = 2; break; + case BX_EDIT_START: + default_choice = 3; break; + default: + default_choice = 5; break; + } + if (ask_uint (startup_menu_prompt, 1, 6, default_choice, &choice, 10) < 0) return -1; switch (choice) { case 1: @@ -425,9 +433,12 @@ int bx_config_interface (int menu) // original state. SIM->reset_all_param (); if (bx_read_rc (NULL) >= 0) - read_rc=1; + SIM->get_param_enum(BXP_BOCHS_START)->set(BX_RUN_START); break; - case 3: bx_config_interface (BX_CI_START_OPTS); break; + case 3: + bx_config_interface (BX_CI_START_OPTS); + SIM->get_param_enum(BXP_BOCHS_START)->set(BX_RUN_START); + break; case 4: bx_write_rc (NULL); break; case 5: bx_config_interface (BX_CI_START_SIMULATION); break; case 6: SIM->quit_sim (1); return -1; @@ -952,7 +963,7 @@ static int ci_callback (void *userdata, ci_command_t command) case CI_START: //fprintf (stderr, "textconfig.cc: start\n"); bx_config_interface_init (); - if (SIM->get_param_bool(BXP_QUICK_START)->get ()) + if (SIM->get_param_enum(BXP_BOCHS_START)->get () == BX_QUICK_START) bx_config_interface (BX_CI_START_SIMULATION); else bx_config_interface (BX_CI_START_MENU); diff --git a/bochs/gui/wxmain.cc b/bochs/gui/wxmain.cc index 7583ea9a0..881addcc1 100644 --- a/bochs/gui/wxmain.cc +++ b/bochs/gui/wxmain.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////// -// $Id: wxmain.cc,v 1.75 2002-11-01 15:28:41 bdenney Exp $ +// $Id: wxmain.cc,v 1.76 2002-11-09 14:12:10 cbothamy Exp $ ///////////////////////////////////////////////////////////////// // // wxmain.cc implements the wxWindows frame, toolbar, menus, and dialogs. @@ -234,7 +234,7 @@ bool MyApp::OnInit() SetTopWindow( frame ); wxTheClipboard->UsePrimarySelection (true); // if quickstart is enabled, kick off the simulation - if (SIM->get_param_bool(BXP_QUICK_START)->get ()) { + if (SIM->get_param_enum(BXP_BOCHS_START)->get () == BX_QUICK_START) { wxCommandEvent unusedEvent; frame->OnStartSim (unusedEvent); } diff --git a/bochs/main.cc b/bochs/main.cc index af7ee55e3..4603a9b3d 100644 --- a/bochs/main.cc +++ b/bochs/main.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: main.cc,v 1.174 2002-11-01 17:53:49 bdenney Exp $ +// $Id: main.cc,v 1.175 2002-11-09 14:12:09 cbothamy Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -335,10 +335,12 @@ void bx_init_options () memset (&bx_options, 0, sizeof(bx_options)); // quick start option, set by command line arg - new bx_param_bool_c (BXP_QUICK_START, - "Quick start", - "Quick start option: if true, read the bochsrc and start simulation immediately", - 0); + new bx_param_enum_c (BXP_BOCHS_START, + "Bochs start types", + "Bochs start types", + bochs_start_names, + BX_RUN_START, + BX_QUICK_START); // floppya bx_options.floppya.Opath = new bx_param_filename_c (BXP_FLOPPYA_PATH, @@ -1486,6 +1488,7 @@ print_usage () int bx_init_main (int argc, char *argv[]) { + bx_bool no_arg = 1; // To deal with initialization order problems inherent in C++, use the macros // SAFE_GET_IOFUNC and SAFE_GET_GENLOG to retrieve "io" and "genlog" in all // constructors or functions called by constructors. The macros test for @@ -1504,10 +1507,7 @@ bx_init_main (int argc, char *argv[]) if (!BX_WITH_WX) bx_print_header (); -#if !BX_USE_CONFIG_INTERFACE - // this allows people to get quick start behavior by default - SIM->get_param_bool(BXP_QUICK_START)->set (1); -#endif + SIM->get_param_enum(BXP_BOCHS_START)->set (BX_RUN_START); // interpret the args that start with -, like -q, -f, etc. int arg = 1; @@ -1518,14 +1518,18 @@ bx_init_main (int argc, char *argv[]) SIM->quit_sim (0); } else if (!strcmp ("-q", argv[arg])) { - SIM->get_param_bool(BXP_QUICK_START)->set (1); + no_arg = 0; + SIM->get_param_enum(BXP_BOCHS_START)->set (BX_QUICK_START); } else if (!strcmp ("-f", argv[arg])) { + no_arg = 0; + SIM->get_param_enum(BXP_BOCHS_START)->set (BX_EDIT_START); if (++arg >= argc) BX_PANIC(("-f must be followed by a filename")); else bochsrc_filename = argv[arg]; } else if (!strcmp ("-qf", argv[arg])) { - SIM->get_param_bool(BXP_QUICK_START)->set (1); + no_arg = 0; + SIM->get_param_enum(BXP_BOCHS_START)->set (BX_QUICK_START); if (++arg >= argc) BX_PANIC(("-qf must be followed by a filename")); else bochsrc_filename = argv[arg]; } @@ -1539,7 +1543,8 @@ bx_init_main (int argc, char *argv[]) arg = argc; // ignore all other args. setupWorkingDirectory (argv[0]); // there is no stdin/stdout so disable the text-based config interface. - SIM->get_param_bool(BXP_QUICK_START)->set (1); + SIM->get_param_enum(BXP_BOCHS_START)->set (BX_QUICK_START); + no_arg = 0; char cwd[MAXPATHLEN]; getwd (cwd); BX_INFO (("Now my working directory is %s", cwd)); @@ -1572,7 +1577,8 @@ bx_init_main (int argc, char *argv[]) if(!isatty(STDIN_FILENO)) { // there is no stdin/stdout so disable the text-based config interface. - SIM->get_param_bool(BXP_QUICK_START)->set (1); + SIM->get_param_enum(BXP_BOCHS_START)->set (BX_QUICK_START); + no_arg = 0; } BX_INFO (("fixing default lib location ...")); // locate the lib directory within the application bundle. @@ -1594,17 +1600,29 @@ bx_init_main (int argc, char *argv[]) CFRelease(libDir); } #endif + +#if !BX_USE_CONFIG_INTERFACE + // this allows people to get quick start behavior by default + SIM->get_param_enum(BXP_BOCHS_START)->set (BX_QUICK_START); +#endif + int norcfile = 1; /* always parse configuration file and command line arguments */ - if (bochsrc_filename == NULL) bochsrc_filename = bx_find_bochsrc (); - if (bochsrc_filename) - norcfile = bx_read_configuration (bochsrc_filename); + if (!no_arg) { + if (bochsrc_filename == NULL) bochsrc_filename = bx_find_bochsrc (); + if (bochsrc_filename) + norcfile = bx_read_configuration (bochsrc_filename); + } + +#if BX_USE_CONFIG_INTERFACE if (norcfile) { // No configuration was loaded, so the current settings are unusable. // Switch off quick start so that we will drop into the configuration // interface. - SIM->get_param_bool(BXP_QUICK_START)->set (0); + SIM->get_param_enum(BXP_BOCHS_START)->set (BX_LOAD_START); } +#endif + // parse the rest of the command line. This is done after reading the // configuration file so that the command line arguments can override // the settings from the file. @@ -1793,7 +1811,7 @@ bx_init_hardware() { // all configuration has been read, now initialize everything. - if (SIM->get_param_bool(BXP_QUICK_START)->get ()) { + if (SIM->get_param_enum(BXP_BOCHS_START)->get ()==BX_QUICK_START) { for (int level=0; levelget_default_log_action (level); #if !BX_USE_CONFIG_INTERFACE @@ -1817,6 +1835,11 @@ bx_init_hardware() bx_generic_apic_c::reset_all_ids (); #endif + // Check if there is a romimage + if (strcmp(bx_options.rom.Opath->getptr (),"") == 0) { + BX_ERROR(("No romimage to load. Is your bochsrc file loaded/valid ?")); + } + #if BX_SMP_PROCESSORS==1 BX_MEM(0)->init_memory(bx_options.memory.Osize->get () * 1024*1024);