From 21b1f8ce580933c235a71a098da1fb06cb5c449c Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Wed, 7 Jun 2006 19:40:15 +0000 Subject: [PATCH] - prepared save state feature using the suspend button and textconfig code rewritten to handle the new toolbar event (TODO: win32 and wx) - suspend button: CR/LF to LF conversion --- bochs/gui/bitmaps/saverestore.h | 52 ++++++++++++++++----------------- bochs/gui/gui.cc | 10 ++++--- bochs/gui/gui.h | 15 +++++----- bochs/gui/siminterface.h | 7 +++-- bochs/gui/textconfig.cc | 45 +++++++++++++++------------- bochs/gui/textconfig.h | 10 +++---- bochs/gui/wxmain.cc | 5 +++- 7 files changed, 78 insertions(+), 66 deletions(-) diff --git a/bochs/gui/bitmaps/saverestore.h b/bochs/gui/bitmaps/saverestore.h index 3cbcfdc58..b52f995c8 100755 --- a/bochs/gui/bitmaps/saverestore.h +++ b/bochs/gui/bitmaps/saverestore.h @@ -1,26 +1,26 @@ -///////////////////////////////////////////////////////////////////////// -// $$ -///////////////////////////////////////////////////////////////////////// - -#define BX_SAVE_RESTORE_BMAP_X 32 -#define BX_SAVE_RESTORE_BMAP_Y 32 - -static const unsigned char bx_save_restore_bmap[(BX_SAVE_RESTORE_BMAP_X * BX_SAVE_RESTORE_BMAP_Y)/8] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2e, 0xdd, 0x9d, 0x3b, - 0x22, 0x45, 0x45, 0x4a, 0x2c, 0xd9, 0x5d, 0x4a, - 0x28, 0x51, 0x44, 0x4a, 0xee, 0x5d, 0x5c, 0x3a, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01, 0x00, - 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01, 0x00, - 0x00, 0xec, 0x0d, 0x00, 0x00, 0xee, 0x1d, 0x00, - 0x00, 0xef, 0x3d, 0x00, 0x00, 0xe7, 0x39, 0x00, - 0x00, 0xe7, 0x39, 0x00, 0x00, 0x07, 0x38, 0x00, - 0x00, 0x07, 0x38, 0x00, 0x00, 0x07, 0x38, 0x00, - 0x00, 0x07, 0x38, 0x00, 0x00, 0x07, 0x38, 0x00, - 0x00, 0xff, 0x3f, 0x00, 0x00, 0xfe, 0x1f, 0x00, - 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; +///////////////////////////////////////////////////////////////////////// +// $Id: saverestore.h,v 1.2 2006-06-07 19:40:15 vruppert Exp $ +///////////////////////////////////////////////////////////////////////// + +#define BX_SAVE_RESTORE_BMAP_X 32 +#define BX_SAVE_RESTORE_BMAP_Y 32 + +static const unsigned char bx_save_restore_bmap[(BX_SAVE_RESTORE_BMAP_X * BX_SAVE_RESTORE_BMAP_Y)/8] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2e, 0xdd, 0x9d, 0x3b, + 0x22, 0x45, 0x45, 0x4a, 0x2c, 0xd9, 0x5d, 0x4a, + 0x28, 0x51, 0x44, 0x4a, 0xee, 0x5d, 0x5c, 0x3a, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01, 0x00, + 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01, 0x00, + 0x00, 0xec, 0x0d, 0x00, 0x00, 0xee, 0x1d, 0x00, + 0x00, 0xef, 0x3d, 0x00, 0x00, 0xe7, 0x39, 0x00, + 0x00, 0xe7, 0x39, 0x00, 0x00, 0x07, 0x38, 0x00, + 0x00, 0x07, 0x38, 0x00, 0x00, 0x07, 0x38, 0x00, + 0x00, 0x07, 0x38, 0x00, 0x00, 0x07, 0x38, 0x00, + 0x00, 0xff, 0x3f, 0x00, 0x00, 0xfe, 0x1f, 0x00, + 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; diff --git a/bochs/gui/gui.cc b/bochs/gui/gui.cc index da1e74237..2dd42fde4 100644 --- a/bochs/gui/gui.cc +++ b/bochs/gui/gui.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: gui.cc,v 1.96 2006-06-06 22:11:08 sshwarts Exp $ +// $Id: gui.cc,v 1.97 2006-06-07 19:40:14 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -120,7 +120,7 @@ void bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheig BX_GUI_THIS host_xres = 640; BX_GUI_THIS host_yres = 480; BX_GUI_THIS host_bpp = 8; - BX_GUI_THIS dialog_caps = BX_GUI_DLG_RUNTIME; + BX_GUI_THIS dialog_caps = BX_GUI_DLG_RUNTIME | BX_GUI_DLG_SAVE_RESTORE; specific_init(argc, argv, tilewidth, tileheight, BX_HEADER_BAR_Y); @@ -504,7 +504,7 @@ void bx_gui_c::paste_handler(void) void bx_gui_c::config_handler(void) { if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_RUNTIME) { - SIM->configuration_interface (NULL, CI_RUNTIME_CONFIG); + SIM->configuration_interface(NULL, CI_RUNTIME_CONFIG); } } @@ -601,7 +601,9 @@ void bx_gui_c::userbutton_handler(void) #if BX_SUPPORT_SAVE_RESTORE void bx_gui_c::save_restore_handler(void) { - BX_INFO(("Save Restore Button Pressed !")); + if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_SAVE_RESTORE) { + SIM->configuration_interface(NULL, CI_SAVE_RESTORE); + } } #endif diff --git a/bochs/gui/gui.h b/bochs/gui/gui.h index 14ac7034c..f50ef11be 100644 --- a/bochs/gui/gui.h +++ b/bochs/gui/gui.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: gui.h,v 1.51 2006-06-06 22:11:08 sshwarts Exp $ +// $Id: gui.h,v 1.52 2006-06-07 19:40:14 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -26,12 +26,13 @@ #define BX_MAX_STATUSITEMS 10 -#define BX_GUI_DLG_FLOPPY 0x01 -#define BX_GUI_DLG_CDROM 0x02 -#define BX_GUI_DLG_SNAPSHOT 0x04 -#define BX_GUI_DLG_RUNTIME 0x08 -#define BX_GUI_DLG_USER 0x10 -#define BX_GUI_DLG_ALL 0x1F +#define BX_GUI_DLG_FLOPPY 0x01 +#define BX_GUI_DLG_CDROM 0x02 +#define BX_GUI_DLG_SNAPSHOT 0x04 +#define BX_GUI_DLG_RUNTIME 0x08 +#define BX_GUI_DLG_USER 0x10 +#define BX_GUI_DLG_SAVE_RESTORE 0x20 +#define BX_GUI_DLG_ALL 0x3F typedef struct { Bit16u start_address; diff --git a/bochs/gui/siminterface.h b/bochs/gui/siminterface.h index 08d5adfe5..8675fbc1a 100644 --- a/bochs/gui/siminterface.h +++ b/bochs/gui/siminterface.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: siminterface.h,v 1.197 2006-06-05 19:06:36 sshwarts Exp $ +// $Id: siminterface.h,v 1.198 2006-06-07 19:40:14 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Intro to siminterface by Bryce Denney: @@ -243,6 +243,9 @@ typedef enum { BX_TOOLBAR_CDROMD, BX_TOOLBAR_RESET, BX_TOOLBAR_POWER, +#if BX_SUPPORT_SAVE_RESTORE + BX_TOOLBAR_SAVE_RESTORE, +#endif BX_TOOLBAR_COPY, BX_TOOLBAR_PASTE, BX_TOOLBAR_SNAPSHOT, @@ -1083,7 +1086,7 @@ BOCHSAPI extern int clock_sync_n_names; #include -enum ci_command_t { CI_START, CI_RUNTIME_CONFIG, CI_SHUTDOWN }; +enum ci_command_t { CI_START, CI_RUNTIME_CONFIG, CI_SAVE_RESTORE, CI_SHUTDOWN }; enum ci_return_t { CI_OK, // normal return value CI_ERR_NO_TEXT_CONSOLE // err: can't work because there's no text console diff --git a/bochs/gui/textconfig.cc b/bochs/gui/textconfig.cc index 33c673c71..623c8bb60 100644 --- a/bochs/gui/textconfig.cc +++ b/bochs/gui/textconfig.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: textconfig.cc,v 1.57 2006-06-04 07:55:34 vruppert Exp $ +// $Id: textconfig.cc,v 1.58 2006-06-07 19:40:15 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // This is code for a text-mode configuration interface. Note that this file @@ -511,30 +511,28 @@ int bx_config_interface(int menu) bx_user_quit = 1; SIM->quit_sim(1); return -1; -#if BX_SUPPORT_SAVE_RESTORE - case BX_CI_RT_SAVE: - if (ask_string("\nWhat is the path to save the Bochs state to?\nTo cancel, type 'none'. [%s] ", "none", sr_path) >= 0) { - if (strcmp (sr_path, "none")) { - if (SIM->save_state(sr_path)) { - Bit32u cont = 0; - ask_yn("\nThe save function currently doesn't handle the state of hard drive images,\n" - "so we don't recommend to continue, unless you are running a read-only\n" - "guest system (e.g. Live-CD).\n\n" - "Do you want to continue? [no]", 0, &cont); - if (!cont) { - bx_user_quit = 1; - SIM->quit_sim(1); - return -1; - } - } - } - } - break; -#endif default: fprintf(stderr, "Menu choice %d not implemented.\n", choice); } } break; + case BX_CI_SAVE_RESTORE: + if (ask_string("\nWhat is the path to save the Bochs state to?\nTo cancel, type 'none'. [%s] ", "none", sr_path) >= 0) { + if (strcmp(sr_path, "none")) { + if (SIM->save_state(sr_path)) { + Bit32u cont = 0; + ask_yn("\nThe save function currently doesn't handle the state of hard drive images,\n" + "so we don't recommend to continue, unless you are running a read-only\n" + "guest system (e.g. Live-CD).\n\n" + "Do you want to continue? [no]", 0, &cont); + if (!cont) { + bx_user_quit = 1; + SIM->quit_sim(1); + return -1; + } + } + } + } + return 0; default: fprintf (stderr, "Unknown config interface menu type.\n"); assert (menu >=0 && menu < BX_CI_N_MENUS); @@ -1013,6 +1011,11 @@ static int ci_callback(void *userdata, ci_command_t command) case CI_RUNTIME_CONFIG: bx_config_interface(BX_CI_RUNTIME); break; + case CI_SAVE_RESTORE: +#if BX_SUPPORT_SAVE_RESTORE + bx_config_interface(BX_CI_SAVE_RESTORE); +#endif + break; case CI_SHUTDOWN: break; } diff --git a/bochs/gui/textconfig.h b/bochs/gui/textconfig.h index 4fb72aeab..fab347800 100644 --- a/bochs/gui/textconfig.h +++ b/bochs/gui/textconfig.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: textconfig.h,v 1.5 2006-04-09 13:55:55 vruppert Exp $ +// $Id: textconfig.h,v 1.6 2006-06-07 19:40:15 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // @@ -18,6 +18,9 @@ enum { BX_CI_START_OPTS_MISC, BX_CI_START_SIMULATION, BX_CI_RUNTIME, +#if BX_SUPPORT_SAVE_RESTORE + BX_CI_SAVE_RESTORE, +#endif BX_CI_N_MENUS }; @@ -33,13 +36,10 @@ enum { BX_CI_RT_LOGOPTS2, BX_CI_RT_INST_TR, BX_CI_RT_MISC, -#if BX_SUPPORT_SAVE_RESTORE - BX_CI_RT_SAVE, -#endif BX_CI_RT_CONT, BX_CI_RT_QUIT }; -int init_text_config_interface (); +int init_text_config_interface(); #endif diff --git a/bochs/gui/wxmain.cc b/bochs/gui/wxmain.cc index 3c6d2f545..0c29b80dd 100644 --- a/bochs/gui/wxmain.cc +++ b/bochs/gui/wxmain.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////// -// $Id: wxmain.cc,v 1.141 2006-06-06 22:11:08 sshwarts Exp $ +// $Id: wxmain.cc,v 1.142 2006-06-07 19:40:15 vruppert Exp $ ///////////////////////////////////////////////////////////////// // // wxmain.cc implements the wxWidgets frame, toolbar, menus, and dialogs. @@ -186,6 +186,9 @@ static int ci_callback(void *userdata, ci_command_t command) case CI_RUNTIME_CONFIG: fprintf(stderr, "wxmain.cc: runtime config not implemented\n"); break; + case CI_SAVE_RESTORE: + fprintf(stderr, "wxmain.cc: save state not implemented\n"); + break; case CI_SHUTDOWN: fprintf(stderr, "wxmain.cc: shutdown not implemented\n"); break;