diff --git a/bochs/gui/Makefile.in b/bochs/gui/Makefile.in index dcd134fac..c67d118bb 100644 --- a/bochs/gui/Makefile.in +++ b/bochs/gui/Makefile.in @@ -64,7 +64,7 @@ GUI_OBJS_RFB = rfb.o GUI_OBJS_AMIGAOS = amigaos.o GUI_OBJS_WX = wx.o GUI_OBJS_WX_SUPPORT = wxmain.o wxdialog.o -OBJS_THAT_CANNOT_BE_PLUGINS = keymap.o gui.o siminterface.o textconfig.o enh_dbg.o @ENH_DBG_OBJS@ @DIALOG_OBJS@ +OBJS_THAT_CANNOT_BE_PLUGINS = keymap.o gui.o siminterface.o paramtree.o textconfig.o enh_dbg.o @ENH_DBG_OBJS@ @DIALOG_OBJS@ OBJS_THAT_CAN_BE_PLUGINS = @GUI_OBJS@ X_LIBS = @X_LIBS@ @@ -186,23 +186,23 @@ dist-clean: clean ########################################### amigaos.o: amigaos.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ - ../gui/siminterface.h ../memory/memory.h ../pc_system.h ../plugin.h \ + ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h ../plugin.h \ ../extplugin.h ../ltdl.h ../gui/gui.h ../instrument/stubs/instrument.h \ ../iodev/iodev.h ../iodev/vga.h beos.o: beos.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h ../iodev/iodev.h \ ../iodev/vga.h carbon.o: carbon.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h enh_dbg.o: enh_dbg.@CPP_SUFFIX@ ../config.h gtk_enh_dbg_osdep.o: gtk_enh_dbg_osdep.@CPP_SUFFIX@ ../config.h gui.o: gui.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h ../gui/bitmaps/floppya.h ../gui/bitmaps/floppyb.h \ @@ -211,47 +211,52 @@ gui.o: gui.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ ../gui/bitmaps/configbutton.h ../gui/bitmaps/cdromd.h \ ../gui/bitmaps/userbutton.h ../gui/bitmaps/saverestore.h keymap.o: keymap.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h macintosh.o: macintosh.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ - ../gui/siminterface.h ../memory/memory.h ../pc_system.h ../plugin.h \ + ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h ../plugin.h \ ../extplugin.h ../ltdl.h ../gui/gui.h ../instrument/stubs/instrument.h \ ../iodev/iodev.h ../iodev/vga.h nogui.o: nogui.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h icon_bochs.h rfb.o: rfb.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h ../iodev/iodev.h \ ../iodev/vga.h icon_bochs.h ../font/vga.bitmap.h sdl.h rfb.h sdl.o: sdl.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h icon_bochs.h sdl.h sdlkeys.h +paramtree.o: paramtree.cc ../bochs.h ../config.h ../osdep.h \ + ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ + ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ + ../pc_system.h ../plugin.h ../extplugin.h ../gui/gui.h \ + ../instrument/stubs/instrument.h paramtree.h siminterface.o: siminterface.@CPP_SUFFIX@ ../iodev/iodev.h ../bochs.h ../config.h \ ../osdep.h ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ - ../gui/siminterface.h ../memory/memory.h ../pc_system.h ../plugin.h \ + ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h ../plugin.h \ ../extplugin.h ../ltdl.h ../gui/gui.h ../instrument/stubs/instrument.h \ ../iodev/vga.h svga.o: svga.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h ../iodev/iodev.h \ ../iodev/vga.h term.o: term.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h ../iodev/iodev.h \ ../iodev/vga.h textconfig.o: textconfig.@CPP_SUFFIX@ ../config.h ../osdep.h textconfig.h \ siminterface.h ../extplugin.h ../ltdl.h win32.o: win32.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h @@ -259,42 +264,42 @@ win32dialog.o: win32dialog.@CPP_SUFFIX@ win32dialog.h ../config.h win32_enh_dbg_osdep.o: win32_enh_dbg_osdep.@CPP_SUFFIX@ ../config.h win32paramdlg.o: win32paramdlg.@CPP_SUFFIX@ win32dialog.h ../config.h wx.o: wx.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h ../font/vga.bitmap.h wxmain.h -wxdialog.o: wxdialog.@CPP_SUFFIX@ ../config.h ../osdep.h ../gui/siminterface.h \ +wxdialog.o: wxdialog.@CPP_SUFFIX@ ../config.h ../osdep.h ../gui/siminterface.h ../gui/paramtree.h \ ../bxversion.h wxdialog.h wxmain.h -wxmain.o: wxmain.@CPP_SUFFIX@ ../config.h ../osdep.h ../gui/siminterface.h \ +wxmain.o: wxmain.@CPP_SUFFIX@ ../config.h ../osdep.h ../gui/siminterface.h ../gui/paramtree.h \ ../bxversion.h wxdialog.h wxmain.h ../extplugin.h ../ltdl.h \ bitmaps/cdromd.xpm bitmaps/copy.xpm bitmaps/floppya.xpm bitmaps/floppyb.xpm \ bitmaps/paste.xpm bitmaps/power.xpm bitmaps/reset.xpm bitmaps/snapshot.xpm \ bitmaps/mouse.xpm bitmaps/userbutton.xpm bitmaps/saverestore.xpm \ icon_bochs.xpm x.o: x.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h enh_dbg.h icon_bochs.xpm ../font/vga.bitmap.h amigaos.lo: amigaos.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ - ../gui/siminterface.h ../memory/memory.h ../pc_system.h ../plugin.h \ + ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h ../plugin.h \ ../extplugin.h ../ltdl.h ../gui/gui.h ../instrument/stubs/instrument.h \ ../iodev/iodev.h ../iodev/vga.h beos.lo: beos.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h ../iodev/iodev.h \ ../iodev/vga.h carbon.lo: carbon.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h enh_dbg.lo: enh_dbg.@CPP_SUFFIX@ ../config.h gtk_enh_dbg_osdep.lo: gtk_enh_dbg_osdep.@CPP_SUFFIX@ ../config.h gui.lo: gui.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h ../gui/bitmaps/floppya.h ../gui/bitmaps/floppyb.h \ @@ -303,47 +308,52 @@ gui.lo: gui.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ ../gui/bitmaps/configbutton.h ../gui/bitmaps/cdromd.h \ ../gui/bitmaps/userbutton.h ../gui/bitmaps/saverestore.h keymap.lo: keymap.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h macintosh.lo: macintosh.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ - ../gui/siminterface.h ../memory/memory.h ../pc_system.h ../plugin.h \ + ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h ../plugin.h \ ../extplugin.h ../ltdl.h ../gui/gui.h ../instrument/stubs/instrument.h \ ../iodev/iodev.h ../iodev/vga.h nogui.lo: nogui.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h icon_bochs.h rfb.lo: rfb.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h ../iodev/iodev.h \ ../iodev/vga.h icon_bochs.h ../font/vga.bitmap.h sdl.h rfb.h sdl.lo: sdl.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h icon_bochs.h sdl.h sdlkeys.h +paramtree.lo: paramtree.cc ../bochs.h ../config.h ../osdep.h \ + ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ + ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ + ../pc_system.h ../plugin.h ../extplugin.h ../gui/gui.h \ + ../instrument/stubs/instrument.h paramtree.h siminterface.lo: siminterface.@CPP_SUFFIX@ ../iodev/iodev.h ../bochs.h ../config.h \ ../osdep.h ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ - ../gui/siminterface.h ../memory/memory.h ../pc_system.h ../plugin.h \ + ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h ../plugin.h \ ../extplugin.h ../ltdl.h ../gui/gui.h ../instrument/stubs/instrument.h \ ../iodev/vga.h svga.lo: svga.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h ../iodev/iodev.h \ ../iodev/vga.h term.lo: term.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h ../iodev/iodev.h \ ../iodev/vga.h textconfig.lo: textconfig.@CPP_SUFFIX@ ../config.h ../osdep.h textconfig.h \ siminterface.h ../extplugin.h ../ltdl.h win32.lo: win32.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h @@ -351,20 +361,20 @@ win32dialog.lo: win32dialog.@CPP_SUFFIX@ win32dialog.h ../config.h win32_enh_dbg_osdep.lo: win32_enh_dbg_osdep.@CPP_SUFFIX@ ../config.h win32paramdlg.lo: win32paramdlg.@CPP_SUFFIX@ win32dialog.h ../config.h wx.lo: wx.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h ../font/vga.bitmap.h wxmain.h -wxdialog.lo: wxdialog.@CPP_SUFFIX@ ../config.h ../osdep.h ../gui/siminterface.h \ +wxdialog.lo: wxdialog.@CPP_SUFFIX@ ../config.h ../osdep.h ../gui/siminterface.h ../gui/paramtree.h \ ../bxversion.h wxdialog.h wxmain.h -wxmain.lo: wxmain.@CPP_SUFFIX@ ../config.h ../osdep.h ../gui/siminterface.h \ +wxmain.lo: wxmain.@CPP_SUFFIX@ ../config.h ../osdep.h ../gui/siminterface.h ../gui/paramtree.h \ ../bxversion.h wxdialog.h wxmain.h ../extplugin.h ../ltdl.h \ bitmaps/cdromd.xpm bitmaps/copy.xpm bitmaps/floppya.xpm bitmaps/floppyb.xpm \ bitmaps/paste.xpm bitmaps/power.xpm bitmaps/reset.xpm bitmaps/snapshot.xpm \ bitmaps/mouse.xpm bitmaps/userbutton.xpm bitmaps/saverestore.xpm \ icon_bochs.xpm x.lo: x.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h ../bx_debug/debug.h \ - ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h \ + ../config.h ../osdep.h ../bxversion.h ../gui/siminterface.h ../gui/paramtree.h \ ../memory/memory.h ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h \ ../gui/gui.h ../instrument/stubs/instrument.h keymap.h ../iodev/iodev.h \ ../iodev/vga.h enh_dbg.h icon_bochs.xpm ../font/vga.bitmap.h diff --git a/bochs/gui/paramtree.cc b/bochs/gui/paramtree.cc new file mode 100755 index 000000000..cbc368065 --- /dev/null +++ b/bochs/gui/paramtree.cc @@ -0,0 +1,1009 @@ +///////////////////////////////////////////////////////////////////////// +// $Id: paramtree.cc,v 1.1 2010-09-16 21:46:45 sshwarts Exp $ +///////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2010 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 +// +///////////////////////////////////////////////////////////////////////// + +#include "bochs.h" +#include "paramtree.h" + +///////////////////////////////////////////////////////////////////////// +// define methods of bx_param_* and family +///////////////////////////////////////////////////////////////////////// + +extern bx_simulator_interface_c *SIM; +extern logfunctions *siminterface_log; +extern bx_list_c *root_param; +#define LOG_THIS siminterface_log-> + +const char* bx_param_c::default_text_format = NULL; + +bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_desc) + : bx_object_c(id), + parent(NULL), + description(NULL), + label(NULL), + ask_format(NULL), + group_name(NULL) +{ + set_type(BXT_PARAM); + this->name = new char[strlen(param_name)+1]; + strcpy(this->name, param_name); + set_description(param_desc); + this->text_format = default_text_format; + this->long_text_format = default_text_format; + this->runtime_param = 0; + this->enabled = 1; + // dependent_list must be initialized before the set(), + // because set calls update_dependents(). + dependent_list = NULL; +} + +bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_label, const char *param_desc) + : bx_object_c(id), + parent(NULL), + description(NULL), + label(NULL), + ask_format(NULL), + group_name(NULL) +{ + set_type(BXT_PARAM); + this->name = new char[strlen(param_name)+1]; + strcpy(this->name, param_name); + set_description(param_desc); + set_label(param_label); + this->text_format = default_text_format; + this->long_text_format = default_text_format; + this->runtime_param = 0; + this->enabled = 1; + // dependent_list must be initialized before the set(), + // because set calls update_dependents(). + dependent_list = NULL; +} + +bx_param_c::~bx_param_c() +{ + delete [] name; + delete [] label; + delete [] description; + delete [] ask_format; + delete [] group_name; +} + +void bx_param_c::set_description(const char *text) +{ + delete [] this->description; + if (text) { + this->description = new char[strlen(text)+1]; + strcpy(this->description, text); + } else { + this->description = NULL; + } +} + +void bx_param_c::set_label(const char *text) +{ + delete [] label; + if (text) { + label = new char[strlen(text)+1]; + strcpy(label, text); + } else { + label = NULL; + } +} + +void bx_param_c::set_ask_format(const char *format) +{ + delete [] ask_format; + if (format) { + ask_format = new char[strlen(format)+1]; + strcpy(ask_format, format); + } else { + ask_format = NULL; + } +} + +void bx_param_c::set_group(const char *group) +{ + delete [] group_name; + if (group) { + group_name = new char[strlen(group)+1]; + strcpy(group_name, group); + } else { + group_name = NULL; + } +} + +int bx_param_c::get_param_path(char *path_out, int maxlen) +{ + if ((get_parent() == NULL) || (get_parent() == root_param)) { + // Start with an empty string. + // Never print the name of the root param. + path_out[0] = 0; + } else { + // build path of the parent, add a period, add path of this node + if (get_parent()->get_param_path(path_out, maxlen) > 0) { + strncat(path_out, ".", maxlen); + } + } + strncat(path_out, name, maxlen); + return strlen(path_out); +} + +const char* bx_param_c::set_default_format(const char *f) +{ + const char *old = default_text_format; + default_text_format = f; + return old; +} + +bx_param_num_c::bx_param_num_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + Bit64s min, Bit64s max, Bit64s initial_val, + bx_bool is_shadow) + : bx_param_c(SIM->gen_param_id(), name, label, description) +{ + set_type(BXT_PARAM_NUM); + this->min = min; + this->max = max; + this->initial_val = initial_val; + this->val.number = initial_val; + this->handler = NULL; + this->save_handler = NULL; + this->restore_handler = NULL; + this->enable_handler = NULL; + this->base = default_base; + this->is_shadow = is_shadow; + if (!is_shadow) { + set(initial_val); + } + if (parent) { + BX_ASSERT(parent->get_type() == BXT_LIST); + this->parent = (bx_list_c *)parent; + this->parent->add(this); + } +} + +Bit32u bx_param_num_c::default_base = BASE_DEC; + +Bit32u bx_param_num_c::set_default_base(Bit32u val) +{ + Bit32u old = default_base; + default_base = val; + return old; +} + +void bx_param_num_c::set_handler(param_event_handler handler) +{ + this->handler = handler; + // now that there's a handler, call set once to run the handler immediately + //set (get ()); +} + +void bx_param_num_c::set_sr_handlers(void *devptr, param_save_handler save, param_restore_handler restore) +{ + sr_devptr = devptr; + save_handler = save; + restore_handler = restore; +} + +void bx_param_num_c::set_dependent_list(bx_list_c *l) +{ + dependent_list = l; + update_dependents(); +} + +Bit64s bx_param_num_c::get64() +{ + if (save_handler) { + return (*save_handler)(sr_devptr, this); + } + if (handler) { + // the handler can decide what value to return and/or do some side effect + return (*handler)(this, 0, val.number); + } else { + // just return the value + return val.number; + } +} + +void bx_param_num_c::set(Bit64s newval) +{ + if (handler) { + // the handler can override the new value and/or perform some side effect + val.number = newval; + (*handler)(this, 1, newval); + } else { + // just set the value. This code does not check max/min. + val.number = newval; + } + if (restore_handler) { + val.number = newval; + (*restore_handler)(sr_devptr, this, newval); + } + if ((val.number < min || val.number > max) && (Bit64u)max != BX_MAX_BIT64U) + BX_PANIC(("numerical parameter '%s' was set to " FMT_LL "d, which is out of range " FMT_LL "d to " FMT_LL "d", get_name (), val.number, min, max)); + if (dependent_list != NULL) update_dependents(); +} + +void bx_param_num_c::set_range(Bit64u min, Bit64u max) +{ + this->min = min; + this->max = max; +} + +void bx_param_num_c::set_initial_val(Bit64s initial_val) +{ + this->val.number = this->initial_val = initial_val; +} + +void bx_param_num_c::update_dependents() +{ + if (dependent_list) { + int en = val.number && enabled; + for (int i=0; iget_size(); i++) { + bx_param_c *param = dependent_list->get(i); + if (param != this) + param->set_enabled(en); + } + } +} + +void bx_param_num_c::set_enabled(int en) +{ + // The enable handler may wish to allow/disallow the action + if (enable_handler) { + en = (*enable_handler)(this, en); + } + bx_param_c::set_enabled(en); + update_dependents(); +} + +// Signed 64 bit +bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit64s *ptr_to_real_val, + int base, + Bit8u highbit, + Bit8u lowbit) +: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT64S, BX_MAX_BIT64S, *ptr_to_real_val, 1) +{ + this->varsize = 64; + this->lowbit = lowbit; + this->mask = ((BX_MAX_BIT64S >> (63 - (highbit - lowbit))) << lowbit); + val.p64bit = ptr_to_real_val; + if (base == BASE_HEX) { + this->base = base; + this->text_format = "0x"FMT_LL"x"; + } +} + +// Unsigned 64 bit +bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit64u *ptr_to_real_val, + int base, + Bit8u highbit, + Bit8u lowbit) +: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT64U, BX_MAX_BIT64U, *ptr_to_real_val, 1) +{ + this->varsize = 64; + this->lowbit = lowbit; + this->mask = ((BX_MAX_BIT64U >> (63 - (highbit - lowbit))) << lowbit); + val.p64bit = (Bit64s*) ptr_to_real_val; + if (base == BASE_HEX) { + this->base = base; + this->text_format = "0x"FMT_LL"x"; + } +} + +// Signed 32 bit +bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit32s *ptr_to_real_val, + int base, + Bit8u highbit, + Bit8u lowbit) +: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT32S, BX_MAX_BIT32S, *ptr_to_real_val, 1) +{ + this->varsize = 32; + this->lowbit = lowbit; + this->mask = ((BX_MAX_BIT32S >> (31 - (highbit - lowbit))) << lowbit); + val.p32bit = ptr_to_real_val; + if (base == BASE_HEX) { + this->base = base; + this->text_format = "0x%08x"; + } +} + +// Unsigned 32 bit +bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit32u *ptr_to_real_val, + int base, + Bit8u highbit, + Bit8u lowbit) +: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT32U, BX_MAX_BIT32U, *ptr_to_real_val, 1) +{ + this->varsize = 32; + this->lowbit = lowbit; + this->mask = ((BX_MAX_BIT32U >> (31 - (highbit - lowbit))) << lowbit); + val.p32bit = (Bit32s*) ptr_to_real_val; + if (base == BASE_HEX) { + this->base = base; + this->text_format = "0x%08x"; + } +} + +// Signed 16 bit +bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit16s *ptr_to_real_val, + int base, + Bit8u highbit, + Bit8u lowbit) +: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT16S, BX_MAX_BIT16S, *ptr_to_real_val, 1) +{ + this->varsize = 16; + this->lowbit = lowbit; + this->mask = ((BX_MAX_BIT16S >> (15 - (highbit - lowbit))) << lowbit); + val.p16bit = ptr_to_real_val; + if (base == BASE_HEX) { + this->base = base; + this->text_format = "0x%04x"; + } +} + +// Unsigned 16 bit +bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit16u *ptr_to_real_val, + int base, + Bit8u highbit, + Bit8u lowbit) +: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT16U, BX_MAX_BIT16U, *ptr_to_real_val, 1) +{ + this->varsize = 16; + this->lowbit = lowbit; + this->mask = ((BX_MAX_BIT16U >> (15 - (highbit - lowbit))) << lowbit); + val.p16bit = (Bit16s*) ptr_to_real_val; + if (base == BASE_HEX) { + this->base = base; + this->text_format = "0x%04x"; + } +} + +// Signed 8 bit +bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit8s *ptr_to_real_val, + int base, + Bit8u highbit, + Bit8u lowbit) +: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT8S, BX_MAX_BIT8S, *ptr_to_real_val, 1) +{ + this->varsize = 8; + this->lowbit = lowbit; + this->mask = ((BX_MAX_BIT8S >> (7 - (highbit - lowbit))) << lowbit); + this->mask = (1 << (highbit - lowbit)) - 1; + val.p8bit = ptr_to_real_val; + if (base == BASE_HEX) { + this->base = base; + this->text_format = "0x%02x"; + } +} + +// Unsigned 8 bit +bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit8u *ptr_to_real_val, + int base, + Bit8u highbit, + Bit8u lowbit) +: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT8U, BX_MAX_BIT8U, *ptr_to_real_val, 1) +{ + this->varsize = 8; + this->lowbit = lowbit; + this->mask = ((BX_MAX_BIT8U >> (7 - (highbit - lowbit))) << lowbit); + val.p8bit = (Bit8s*) ptr_to_real_val; + if (base == BASE_HEX) { + this->base = base; + this->text_format = "0x%02x"; + } +} + +Bit64s bx_shadow_num_c::get64() +{ + Bit64u current = 0; + switch (varsize) { + case 8: current = *(val.p8bit); break; + case 16: current = *(val.p16bit); break; + case 32: current = *(val.p32bit); break; + case 64: current = *(val.p64bit); break; + default: BX_PANIC(("unsupported varsize %d", varsize)); + } + current = (current >> lowbit) & mask; + if (handler) { + // the handler can decide what value to return and/or do some side effect + return (*handler)(this, 0, current) & mask; + } else { + // just return the value + return current; + } +} + +void bx_shadow_num_c::set(Bit64s newval) +{ + Bit64u tmp = 0; + if (((newval < min) || (newval > max)) && (min != BX_MIN_BIT64S) && ((Bit64u)max != BX_MAX_BIT64U)) + BX_PANIC(("numerical parameter %s was set to " FMT_LL "d, which is out of range " FMT_LL "d to " FMT_LL "d", get_name (), newval, min, max)); + switch (varsize) { + case 8: + tmp = *(val.p8bit) & ~(mask << lowbit); + tmp |= (newval & mask) << lowbit; + *(val.p8bit) = (Bit8s)tmp; + break; + case 16: + tmp = *(val.p16bit) & ~(mask << lowbit); + tmp |= (newval & mask) << lowbit; + *(val.p16bit) = (Bit16s)tmp; + break; + case 32: + tmp = *(val.p32bit) & ~(mask << lowbit); + tmp |= (newval & mask) << lowbit; + *(val.p32bit) = (Bit32s)tmp; + break; + case 64: + tmp = *(val.p64bit) & ~(mask << lowbit); + tmp |= (newval & mask) << lowbit; + *(val.p64bit) = (Bit64s)tmp; + break; + default: + BX_PANIC(("unsupported varsize %d", varsize)); + } + if (handler) { + // the handler can override the new value and/or perform some side effect + (*handler)(this, 1, tmp); + } +} + +void bx_shadow_num_c::reset() +{ + BX_PANIC(("reset not supported on bx_shadow_num_c yet")); +} + +bx_param_bool_c::bx_param_bool_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + Bit64s initial_val, + bx_bool is_shadow) + : bx_param_num_c(parent, name, label, description, 0, 1, initial_val, is_shadow) +{ + set_type(BXT_PARAM_BOOL); +} + +bx_shadow_bool_c::bx_shadow_bool_c(bx_param_c *parent, + const char *name, + const char *label, + bx_bool *ptr_to_real_val, + Bit8u bitnum) + : bx_param_bool_c(parent, name, label, NULL, (Bit64s) *ptr_to_real_val, 1) +{ + val.pbool = ptr_to_real_val; + this->bitnum = bitnum; +} + +bx_shadow_bool_c::bx_shadow_bool_c(bx_param_c *parent, + const char *name, + bx_bool *ptr_to_real_val, + Bit8u bitnum) + : bx_param_bool_c(parent, name, NULL, NULL, (Bit64s) *ptr_to_real_val, 1) +{ + val.pbool = ptr_to_real_val; + this->bitnum = bitnum; +} + +Bit64s bx_shadow_bool_c::get64() +{ + if (handler) { + // the handler can decide what value to return and/or do some side effect + Bit64s ret = (*handler)(this, 0, (Bit64s) *(val.pbool)); + return (ret>>bitnum) & 1; + } else { + // just return the value + return (*(val.pbool)) & 1; + } +} + +void bx_shadow_bool_c::set(Bit64s newval) +{ + // only change the bitnum bit + Bit64s tmp = (newval&1) << bitnum; + *(val.pbool) &= ~tmp; + *(val.pbool) |= tmp; + if (handler) { + // the handler can override the new value and/or perform some side effect + (*handler)(this, 1, newval&1); + } +} + +bx_param_enum_c::bx_param_enum_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + const char **choices, + Bit64s initial_val, + Bit64s value_base) + : bx_param_num_c(parent, name, label, description, value_base, BX_MAX_BIT64S, initial_val) +{ + set_type(BXT_PARAM_ENUM); + this->choices = choices; + // count number of choices, set max + const char **p = choices; + while (*p != NULL) p++; + this->min = value_base; + // now that the max is known, replace the BX_MAX_BIT64S sent to the parent + // class constructor with the real max. + this->max = value_base + (p - choices - 1); + this->deps_bitmap = NULL; + set(initial_val); +} + +bx_param_enum_c::~bx_param_enum_c() +{ + if (deps_bitmap != NULL) { + free(deps_bitmap); + } +} + + +void bx_param_enum_c::set(Bit64s val) +{ + bx_param_num_c::set(val); + update_dependents(); +} + +int bx_param_enum_c::find_by_name(const char *string) +{ + const char **p; + for (p=&choices[0]; *p; p++) { + if (!strcmp(string, *p)) + return p-choices; + } + return -1; +} + +bx_bool bx_param_enum_c::set_by_name(const char *string) +{ + int n = find_by_name(string); + if (n<0) return 0; + set(n + min); + return 1; +} + +void bx_param_enum_c::set_dependent_list(bx_list_c *l, bx_bool enable_all) +{ + dependent_list = l; + deps_bitmap = (Bit64u*)malloc(sizeof(Bit64u) * (max - min + 1)); + for (int i=0; i<(max-min+1); i++) { + if (enable_all) { + deps_bitmap[i] = (1 << (l->get_size())) - 1; + } else { + deps_bitmap[i] = 0; + } + } + update_dependents(); +} + +void bx_param_enum_c::set_dependent_bitmap(Bit64s value, Bit64u bitmap) +{ + if (deps_bitmap != NULL) { + deps_bitmap[value - min] = bitmap; + } + update_dependents(); +} + +Bit64u bx_param_enum_c::get_dependent_bitmap(Bit64s value) +{ + if (deps_bitmap != NULL) { + return deps_bitmap[value - min]; + } + return 0; +} + +void bx_param_enum_c::update_dependents() +{ + if ((dependent_list != NULL) && (deps_bitmap != NULL)) { + Bit64u en_bmap = deps_bitmap[val.number - min]; + Bit64u mask = 0x1; + for (int i=0; iget_size(); i++) { + int en = (en_bmap & mask) && enabled; + bx_param_c *param = dependent_list->get(i); + if (param != this) + param->set_enabled(en); + mask <<= 1; + } + } +} + +void bx_param_enum_c::set_enabled(int en) +{ + // The enable handler may wish to allow/disallow the action + if (enable_handler) { + en = (*enable_handler)(this, en); + } + bx_param_c::set_enabled(en); + update_dependents(); +} + +bx_param_string_c::bx_param_string_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + const char *initial_val, + int maxsize) + : bx_param_c(SIM->gen_param_id(), name, label, description) +{ + set_type(BXT_PARAM_STRING); + int initial_val_size = strlen(initial_val) + 1; + if (maxsize < 0) { + maxsize = initial_val_size; + } else if (initial_val_size > maxsize) { + initial_val_size = maxsize; + } + this->val = new char[maxsize]; + this->initial_val = new char[maxsize]; + this->handler = NULL; + this->enable_handler = NULL; + this->maxsize = maxsize; + strncpy(this->val, initial_val, initial_val_size); + if (maxsize > initial_val_size) + memset(this->val + initial_val_size, 0, maxsize - initial_val_size); + strncpy(this->initial_val, initial_val, maxsize); + this->options = 0; + set(initial_val); + if (parent) { + BX_ASSERT(parent->get_type() == BXT_LIST); + this->parent = (bx_list_c *)parent; + this->parent->add(this); + } +} + +bx_param_filename_c::bx_param_filename_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + const char *initial_val, + int maxsize) + : bx_param_string_c(parent, name, label, description, initial_val, maxsize) +{ + set_options(IS_FILENAME); + ext = NULL; +} + +bx_param_string_c::~bx_param_string_c() +{ + if (val != NULL) delete [] val; + if (initial_val != NULL) delete [] initial_val; +} + +void bx_param_string_c::reset() +{ + set(initial_val); +} + +void bx_param_string_c::set_handler(param_string_event_handler handler) +{ + this->handler = handler; +} + +void bx_param_string_c::set_enable_handler(param_enable_handler handler) +{ + this->enable_handler = handler; +} + +void bx_param_string_c::update_dependents() +{ + if (dependent_list) { + int en = (strlen(val) > 0) && (strcmp(val, "none")) && enabled; + for (int i=0; iget_size(); i++) { + bx_param_c *param = dependent_list->get(i); + if (param != this) + param->set_enabled(en); + } + } +} + +void bx_param_string_c::set_enabled(int en) +{ + // The enable handler may wish to allow/disallow the action + if (enable_handler) { + en = (*enable_handler)(this, en); + } + bx_param_c::set_enabled(en); + if (dependent_list != NULL) update_dependents(); +} + +void bx_param_string_c::set_dependent_list(bx_list_c *l) +{ + dependent_list = l; + update_dependents(); +} + +Bit32s bx_param_string_c::get(char *buf, int len) +{ + if (options & RAW_BYTES) + memcpy(buf, val, len); + else + strncpy(buf, val, len); + if (handler) { + // the handler can choose to replace the value in val/len. Also its + // return value is passed back as the return value of get. + (*handler)(this, 0, buf, buf, len); + } + return 0; +} + +void bx_param_string_c::set(const char *buf) +{ + char *oldval = new char[maxsize]; + + if (options & RAW_BYTES) { + memcpy(oldval, val, maxsize); + memcpy(val, buf, maxsize); + } else { + strncpy(oldval, val, maxsize); + oldval[maxsize - 1] = 0; + strncpy(val, buf, maxsize); + val[maxsize - 1] = 0; + } + if (handler) { + // the handler can return a different char* to be copied into the value + buf = (*handler)(this, 1, oldval, buf, -1); + } + delete [] oldval; + if (dependent_list != NULL) update_dependents(); +} + +bx_bool bx_param_string_c::equals(const char *buf) +{ + if (options & RAW_BYTES) + return (memcmp(val, buf, maxsize) == 0); + else + return (strncmp(val, buf, maxsize) == 0); +} + +void bx_param_string_c::set_initial_val(const char *buf) +{ + if (options & RAW_BYTES) + memcpy(initial_val, buf, maxsize); + else + strncpy(initial_val, buf, maxsize); + set(initial_val); +} + +bx_shadow_data_c::bx_shadow_data_c(bx_param_c *parent, + const char *name, + Bit8u *ptr_to_data, + Bit32u data_size) + : bx_param_c(SIM->gen_param_id(), name, "") +{ + set_type(BXT_PARAM_DATA); + this->data_ptr = ptr_to_data; + this->data_size = data_size; + if (parent) { + BX_ASSERT(parent->get_type() == BXT_LIST); + this->parent = (bx_list_c *)parent; + this->parent->add(this); + } +} + +bx_list_c::bx_list_c(bx_param_c *parent, int maxsize) + : bx_param_c(SIM->gen_param_id(), "list", "") +{ + set_type(BXT_LIST); + this->size = 0; + this->maxsize = maxsize; + this->list = new bx_param_c* [maxsize]; + this->parent = NULL; + if (parent) { + BX_ASSERT(parent->get_type() == BXT_LIST); + this->parent = (bx_list_c *)parent; + this->parent->add(this); + } + init(""); +} + +bx_list_c::bx_list_c(bx_param_c *parent, const char *name, int maxsize) + : bx_param_c(SIM->gen_param_id(), name, "") +{ + set_type (BXT_LIST); + this->size = 0; + this->maxsize = maxsize; + this->list = new bx_param_c* [maxsize]; + this->parent = NULL; + if (parent) { + BX_ASSERT(parent->get_type() == BXT_LIST); + this->parent = (bx_list_c *)parent; + this->parent->add(this); + } + init(""); +} + +bx_list_c::bx_list_c(bx_param_c *parent, const char *name, const char *title, + int maxsize) + : bx_param_c(SIM->gen_param_id(), name, "") +{ + set_type (BXT_LIST); + this->size = 0; + this->maxsize = maxsize; + this->list = new bx_param_c* [maxsize]; + this->parent = NULL; + if (parent) { + BX_ASSERT(parent->get_type() == BXT_LIST); + this->parent = (bx_list_c *)parent; + this->parent->add(this); + } + init(title); +} + +bx_list_c::bx_list_c(bx_param_c *parent, const char *name, const char *title, bx_param_c **init_list) + : bx_param_c(SIM->gen_param_id(), name, "") +{ + set_type(BXT_LIST); + this->size = 0; + while (init_list[this->size] != NULL) + this->size++; + this->maxsize = this->size; + this->list = new bx_param_c* [maxsize]; + for (int i=0; isize; i++) + this->list[i] = init_list[i]; + this->parent = NULL; + if (parent) { + BX_ASSERT(parent->get_type() == BXT_LIST); + this->parent = (bx_list_c *)parent; + this->parent->add(this); + } + init(title); +} + +bx_list_c::~bx_list_c() +{ + if (list != NULL) { + for (int i=0; ititle = new bx_param_string_c(NULL, + "list_title", + "", "", + get_name(), 80); + if ((list_title != NULL) && (strlen(list_title) > 0)) { + this->title->set((char *)list_title); + } + this->options = 0; + this->choice = new bx_param_num_c(NULL, + "list_choice", "", "", 0, BX_MAX_BIT64S, 1); +} + +void bx_list_c::set_parent(bx_param_c *newparent) +{ + if (parent) { + // if this object already had a parent, the correct thing + // to do would be to remove this object from the parent's + // list of children. Deleting children is currently + // not supported. + BX_PANIC(("bx_list_c::set_parent: changing from one parent to another is not supported")); + } + if (newparent) { + BX_ASSERT(newparent->get_type() == BXT_LIST); + parent = (bx_list_c *)newparent; + parent->add(this); + } +} + +bx_list_c* bx_list_c::clone() +{ + bx_list_c *newlist = new bx_list_c(NULL, name, title->getptr(), maxsize); + for (int i=0; iadd(get(i)); + newlist->set_options(options); + return newlist; +} + +void bx_list_c::add(bx_param_c *param) +{ + if (size >= maxsize) { + BX_PANIC(("add param '%s' to bx_list_c '%s': list capacity exceeded", + param->get_name(), get_name())); + return; + } + list[size] = param; + size++; +} + +bx_param_c* bx_list_c::get(int index) +{ + BX_ASSERT(index >= 0 && index < size); + return list[index]; +} + +bx_param_c* bx_list_c::get_by_name(const char *name) +{ + int imax = get_size(); + for (int i=0; iget_name())) { + return p; + } + } + return NULL; +} + +void bx_list_c::reset() +{ + int imax = get_size(); + for (int i=0; ireset(); + } +} + +void bx_list_c::clear() +{ + int imax = get_size(); + for (int i=0; iget_parent() == this) { + delete param; + } + } + size = 0; +} + +void bx_list_c::remove(const char *name) +{ + int imax = get_size(); + int found = 0; + for (int i=0; iget_name())) { + if (p->get_parent() == this) { + delete p; + } + found = 1; + } + if (found) { + list[i] = list[i+1]; + } + } + if (found) { + size--; + } +} diff --git a/bochs/gui/paramtree.h b/bochs/gui/paramtree.h new file mode 100755 index 000000000..b3e940337 --- /dev/null +++ b/bochs/gui/paramtree.h @@ -0,0 +1,461 @@ +///////////////////////////////////////////////////////////////////////// +// $Id: paramtree.h,v 1.1 2010-09-16 21:46:45 sshwarts Exp $ +///////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2010 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 +// +///////////////////////////////////////////////////////////////////////// + +#ifndef BX_PARAM_TREE_H +#define BX_PARAM_TREE_H + +//////////////////////////////////////////////////////////////////// +// parameter classes: bx_param_c and family +//////////////////////////////////////////////////////////////////// +// +// All variables that can be configured through the CI are declared as +// "parameters" or objects of type bx_param_*. There is a bx_param_* +// class for each type of data that the user would need to see and +// edit, e.g. integer, boolean, enum, string, filename, or list of +// other parameters. The purpose of the bx_param_* class, in addition +// to storing the parameter's value, is to hold the name, description, +// and constraints on the value. The bx_param_* class should hold +// everything that the CI would need to display the value and allow +// the user to modify it. For integer parameters, the minimum and +// maximum allowed value can be defined, and the base in which it +// should be displayed and interpreted. For enums, the +// bx_param_enum_c structure includes the list of values which the +// parameter can have. +// +// Also, some parameter classes support get/set callback functions to +// allow arbitrary code to be executed when the parameter is get/set. +// An example of where this is useful: if you disable the NE2K card, +// the set() handler for that parameter can tell the user interface +// that the NE2K's irq, I/O address, and mac address should be +// disabled (greyed out, hidden, or made inaccessible). The get/set +// methods can also check if the set() value is acceptable using +// whatever means and override it. +// +// The parameter concept is similar to the use of parameters in JavaBeans. + +class bx_object_c; +class bx_param_c; +class bx_param_num_c; +class bx_param_enum_c; +class bx_param_bool_c; +class bx_param_string_c; +class bx_param_filename_c; +class bx_list_c; + +class BOCHSAPI bx_object_c { +private: + Bit32u id; + bx_objtype type; +protected: + void set_type(bx_objtype _type) { type = _type; } +public: + bx_object_c(Bit32u _id): id(_id), type(BXT_OBJECT) {} + virtual ~bx_object_c() {} + Bit32u get_id() const { return id; } + Bit8u get_type() const { return type; } +}; + +#define BASE_DEC 10 +#define BASE_HEX 16 + +class BOCHSAPI bx_param_c : public bx_object_c { + BOCHSAPI_CYGONLY static const char *default_text_format; +protected: + bx_list_c *parent; + char *name; + char *description; + char *label; // label string for text menus and gui dialogs + const char *text_format; // printf format string. %d for ints, %s for strings, etc. + const char *long_text_format; // printf format string. %d for ints, %s for strings, etc. + char *ask_format; // format string for asking for a new value + char *group_name; // name of the group the param belongs to + int runtime_param; + int enabled; + Bit32u options; + // The dependent_list is initialized to NULL. If dependent_list is modified + // to point to a bx_list_c of other parameters, the set() method of the + // parameter type will enable those parameters when the enable condition is + // true, and disable them it is false. + bx_list_c *dependent_list; + void *device; +public: + bx_param_c(Bit32u id, const char *name, const char *description); + bx_param_c(Bit32u id, const char *name, const char *label, const char *description); + virtual ~bx_param_c(); + bx_param_c *get_parent() { return (bx_param_c *) parent; } + int get_param_path(char *path_out, int maxlen); + void set_format(const char *format) {text_format = format;} + const char *get_format() const {return text_format;} + void set_long_format(const char *format) {long_text_format = format;} + const char *get_long_format() const {return long_text_format;} + void set_ask_format(const char *format); + const char *get_ask_format() const {return ask_format;} + void set_label(const char *text); + void set_description(const char *text); + const char *get_label() const {return label;} + void set_runtime_param(int val) { runtime_param = val; } + int get_runtime_param() { return runtime_param; } + void set_group(const char *group); + const char *get_group() const {return group_name;} + const char *get_name() const { return name; } + const char *get_description() const { return description; } + int get_enabled() const { return enabled; } + virtual void set_enabled(int enabled) { this->enabled = enabled; } + virtual void reset() {} + int getint() const {return -1;} + static const char* set_default_format(const char *f); + static const char *get_default_format() { return default_text_format; } + bx_list_c *get_dependent_list() { return dependent_list; } + void set_options(Bit32u options) { this->options = options; } + Bit32u get_options() const { return options; } + void set_device_param(void *dev) { device = dev; } + void *get_device_param() { return device; } +#if BX_USE_TEXTCONFIG + virtual void text_print(FILE *fp) {} + virtual int text_ask(FILE *fpin, FILE *fpout) {return -1;} +#endif +}; + +typedef Bit64s (*param_event_handler)(class bx_param_c *, int set, Bit64s val); +typedef Bit64s (*param_save_handler)(void *devptr, class bx_param_c *); +typedef void (*param_restore_handler)(void *devptr, class bx_param_c *, Bit64s val); +typedef int (*param_enable_handler)(class bx_param_c *, int en); + +class BOCHSAPI bx_param_num_c : public bx_param_c { + BOCHSAPI_CYGONLY static Bit32u default_base; + void update_dependents(); +protected: + Bit64s min, max, initial_val; + union _uval_ { + Bit64s number; // used by bx_param_num_c + Bit64s *p64bit; // used by bx_shadow_num_c + Bit32s *p32bit; // used by bx_shadow_num_c + Bit16s *p16bit; // used by bx_shadow_num_c + Bit8s *p8bit; // used by bx_shadow_num_c + bx_bool *pbool; // used by bx_shadow_bool_c + } val; + param_event_handler handler; + void *sr_devptr; + param_save_handler save_handler; + param_restore_handler restore_handler; + param_enable_handler enable_handler; + int base; + bx_bool is_shadow; +public: + enum { + // When a bx_param_num_c is displayed in dialog, USE_SPIN_CONTROL controls + // whether a spin control should be used instead of a simple text control. + USE_SPIN_CONTROL = (1<<0) + } bx_numopt_bits; + bx_param_num_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + Bit64s min, Bit64s max, Bit64s initial_val, + bx_bool is_shadow = 0); + virtual void reset() { val.number = initial_val; } + void set_handler(param_event_handler handler); + void set_sr_handlers(void *devptr, param_save_handler save, param_restore_handler restore); + void set_enable_handler(param_enable_handler handler) { enable_handler = handler; } + void set_dependent_list(bx_list_c *l); + virtual void set_enabled(int enabled); + virtual Bit32s get() { return (Bit32s) get64(); } + virtual Bit64s get64(); + virtual void set(Bit64s val); + void set_base(int base) { this->base = base; } + void set_initial_val(Bit64s initial_val); + int get_base() const { return base; } + void set_range(Bit64u min, Bit64u max); + Bit64s get_min() { return min; } + Bit64s get_max() { return max; } + static Bit32u set_default_base(Bit32u val); + static Bit32u get_default_base() { return default_base; } +#if BX_USE_TEXTCONFIG + virtual void text_print(FILE *fp); + virtual int text_ask(FILE *fpin, FILE *fpout); +#endif +}; + +// a bx_shadow_num_c is like a bx_param_num_c except that it doesn't +// store the actual value with its data. Instead, it uses val.p32bit +// to keep a pointer to the actual data. This is used to register +// existing variables as parameters, without having to access it via +// set/get methods. +class BOCHSAPI bx_shadow_num_c : public bx_param_num_c { + Bit8u varsize; // must be 64, 32, 16, or 8 + Bit8u lowbit; // range of bits associated with this param + Bit64u mask; // mask is ANDed with value before it is returned from get +public: + bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit64s *ptr_to_real_val, + int base = BASE_DEC, + Bit8u highbit = 63, + Bit8u lowbit = 0); + bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit64u *ptr_to_real_val, + int base = BASE_DEC, + Bit8u highbit = 63, + Bit8u lowbit = 0); + bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit32s *ptr_to_real_val, + int base = BASE_DEC, + Bit8u highbit = 31, + Bit8u lowbit = 0); + bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit32u *ptr_to_real_val, + int base = BASE_DEC, + Bit8u highbit = 31, + Bit8u lowbit = 0); + bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit16s *ptr_to_real_val, + int base = BASE_DEC, + Bit8u highbit = 15, + Bit8u lowbit = 0); + bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit16u *ptr_to_real_val, + int base = BASE_DEC, + Bit8u highbit = 15, + Bit8u lowbit = 0); + bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit8s *ptr_to_real_val, + int base = BASE_DEC, + Bit8u highbit = 7, + Bit8u lowbit = 0); + bx_shadow_num_c(bx_param_c *parent, + const char *name, + Bit8u *ptr_to_real_val, + int base = BASE_DEC, + Bit8u highbit = 7, + Bit8u lowbit = 0); + virtual Bit64s get64(); + virtual void set(Bit64s val); + virtual void reset(); +}; + +class BOCHSAPI bx_param_bool_c : public bx_param_num_c { + // many boolean variables are used to enable/disable modules. In the + // user interface, the enable variable should enable/disable all the + // other parameters associated with that module. +public: + bx_param_bool_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + Bit64s initial_val, + bx_bool is_shadow = 0); +#if BX_USE_TEXTCONFIG + virtual void text_print(FILE *fp); + virtual int text_ask(FILE *fpin, FILE *fpout); +#endif +}; + +// a bx_shadow_bool_c is a shadow param based on bx_param_bool_c. +class BOCHSAPI bx_shadow_bool_c : public bx_param_bool_c { + // each bit of a bitfield can be a separate value. bitnum tells which + // bit is used. get/set will only modify that bit. + Bit8u bitnum; +public: + bx_shadow_bool_c(bx_param_c *parent, + const char *name, + const char *label, + bx_bool *ptr_to_real_val, + Bit8u bitnum = 0); + bx_shadow_bool_c(bx_param_c *parent, + const char *name, + bx_bool *ptr_to_real_val, + Bit8u bitnum = 0); + virtual Bit64s get64(); + virtual void set(Bit64s val); +}; + + +class BOCHSAPI bx_param_enum_c : public bx_param_num_c { + const char **choices; + Bit64u *deps_bitmap; + void update_dependents(); +public: + bx_param_enum_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + const char **choices, + Bit64s initial_val, + Bit64s value_base = 0); + virtual ~bx_param_enum_c(); + const char *get_choice(int n) { return choices[n]; } + const char *get_selected() { return choices[val.number - min]; } + int find_by_name(const char *string); + virtual void set(Bit64s val); + bx_bool set_by_name(const char *string); + void set_dependent_list(bx_list_c *l, bx_bool enable_all); + void set_dependent_bitmap(Bit64s value, Bit64u bitmap); + Bit64u get_dependent_bitmap(Bit64s value); + virtual void set_enabled(int enabled); +#if BX_USE_TEXTCONFIG + virtual void text_print(FILE *fp); + virtual int text_ask(FILE *fpin, FILE *fpout); +#endif +}; + +typedef const char* (*param_string_event_handler)(class bx_param_string_c *, + int set, const char *oldval, const char *newval, int maxlen); + +class BOCHSAPI bx_param_string_c : public bx_param_c { + int maxsize; + char *val, *initial_val; + param_string_event_handler handler; + param_enable_handler enable_handler; + char separator; + void update_dependents(); +public: + enum { + RAW_BYTES = 1, // use binary text editor, like MAC addr + IS_FILENAME = 2, // 1=yes it's a filename, 0=not a filename. + // Some guis have a file browser. This + // bit suggests that they use it. + SAVE_FILE_DIALOG = 4, // Use save dialog opposed to open file dialog + SELECT_FOLDER_DLG = 8 // Use folder selection dialog + } bx_string_opt_bits; + bx_param_string_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + const char *initial_val, + int maxsize=-1); + virtual ~bx_param_string_c(); + virtual void reset(); + void set_handler(param_string_event_handler handler); + void set_enable_handler(param_enable_handler handler); + virtual void set_enabled(int enabled); + void set_dependent_list(bx_list_c *l); + Bit32s get(char *buf, int len); + char *getptr() {return val; } + void set(const char *buf); + bx_bool equals(const char *buf); + void set_separator(char sep) {separator = sep; } + char get_separator() const {return separator; } + int get_maxsize() const {return maxsize; } + void set_initial_val(const char *buf); +#if BX_USE_TEXTCONFIG + virtual void text_print(FILE *fp); + virtual int text_ask(FILE *fpin, FILE *fpout); +#endif +}; + +// Declare a filename class. It is identical to a string, except that +// it initializes the options differently. This is just a shortcut +// for declaring a string param and setting the options with IS_FILENAME. +class BOCHSAPI bx_param_filename_c : public bx_param_string_c { +const char *ext; +public: + bx_param_filename_c(bx_param_c *parent, + const char *name, + const char *label, + const char *description, + const char *initial_val, + int maxsize=-1); + const char *get_extension() {return ext;} + void set_extension(const char *ext) {this->ext = ext;} +}; + +class BOCHSAPI bx_shadow_data_c : public bx_param_c { + Bit32u data_size; + Bit8u *data_ptr; +public: + bx_shadow_data_c(bx_param_c *parent, + const char *name, + Bit8u *ptr_to_data, + Bit32u data_size); + Bit8u *getptr() {return data_ptr;} + Bit32u get_size() const {return data_size;} +}; + +#define BX_DEFAULT_LIST_SIZE 6 + +class BOCHSAPI bx_list_c : public bx_param_c { +protected: + // just a list of bx_param_c objects. size tells current number of + // objects in the list, and maxsize tells how many list items are + // allocated in the constructor. + bx_param_c **list; + int size, maxsize; + // for a menu, the value of choice before the call to "ask" is default. + // After ask, choice holds the value that the user chose. Choice defaults + // to 1 in the constructor. + bx_param_num_c *choice; + // title of the menu or series + bx_param_string_c *title; + void init(const char *list_title); +public: + enum { + // When a bx_list_c is displayed as a menu, SHOW_PARENT controls whether or + // not the menu shows a "Return to parent menu" choice or not. + SHOW_PARENT = (1<<0), + // Some lists are best displayed shown as menus, others as a series of + // related questions. This bit suggests to the CI that the series of + // questions format is preferred. + SERIES_ASK = (1<<1), + // When a bx_list_c is displayed in a dialog, USE_TAB_WINDOW suggests + // to the CI that each item in the list should be shown as a separate + // tab. This would be most appropriate when each item is another list + // of parameters. + USE_TAB_WINDOW = (1<<2), + // When a bx_list_c is displayed in a dialog, the list name is used as the + // label of the group box if USE_BOX_TITLE is set. This is only necessary if + // more than one list appears in a dialog box. + USE_BOX_TITLE = (1<<3), + // When a bx_list_c is displayed as a menu, SHOW_GROUP_NAME controls whether + // or not the name of group the item belongs to is added to the name of the + // item (used in the runtime menu). + SHOW_GROUP_NAME = (1<<4) + } bx_listopt_bits; + bx_list_c(bx_param_c *parent, int maxsize); + bx_list_c(bx_param_c *parent, const char *name, int maxsize); + bx_list_c(bx_param_c *parent, const char *name, const char *title, int maxsize = BX_DEFAULT_LIST_SIZE); + bx_list_c(bx_param_c *parent, const char *name, const char *title, bx_param_c **init_list); + virtual ~bx_list_c(); + bx_list_c *clone(); + void add(bx_param_c *param); + bx_param_c *get(int index); + bx_param_c *get_by_name(const char *name); + int get_size() const { return size; } + bx_param_num_c *get_choice() { return choice; } + bx_param_string_c *get_title() { return title; } + void set_parent(bx_param_c *newparent); + bx_param_c *get_parent() { return parent; } + virtual void reset(); + virtual void clear(); + virtual void remove(const char *name); +#if BX_USE_TEXTCONFIG + virtual void text_print(FILE *); + virtual int text_ask(FILE *fpin, FILE *fpout); +#endif +}; + +#endif diff --git a/bochs/gui/siminterface.cc b/bochs/gui/siminterface.cc index 328666e55..4a794bc6d 100644 --- a/bochs/gui/siminterface.cc +++ b/bochs/gui/siminterface.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: siminterface.cc,v 1.214 2010-09-12 20:47:23 sshwarts Exp $ +// $Id: siminterface.cc,v 1.215 2010-09-16 21:46:45 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2009 The Bochs Project @@ -1245,983 +1245,3 @@ bx_bool bx_real_sim_c::save_sr_param(FILE *fp, bx_param_c *node, const char *sr_ return 1; } - -///////////////////////////////////////////////////////////////////////// -// define methods of bx_param_* and family -///////////////////////////////////////////////////////////////////////// - -const char* bx_param_c::default_text_format = NULL; - -bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_desc) - : bx_object_c(id), - parent(NULL), - description(NULL), - label(NULL), - ask_format(NULL), - group_name(NULL) -{ - set_type(BXT_PARAM); - this->name = new char[strlen(param_name)+1]; - strcpy(this->name, param_name); - set_description(param_desc); - this->text_format = default_text_format; - this->long_text_format = default_text_format; - this->runtime_param = 0; - this->enabled = 1; - // dependent_list must be initialized before the set(), - // because set calls update_dependents(). - dependent_list = NULL; -} - -bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_label, const char *param_desc) - : bx_object_c(id), - parent(NULL), - description(NULL), - label(NULL), - ask_format(NULL), - group_name(NULL) -{ - set_type(BXT_PARAM); - this->name = new char[strlen(param_name)+1]; - strcpy(this->name, param_name); - set_description(param_desc); - set_label(param_label); - this->text_format = default_text_format; - this->long_text_format = default_text_format; - this->runtime_param = 0; - this->enabled = 1; - // dependent_list must be initialized before the set(), - // because set calls update_dependents(). - dependent_list = NULL; -} - -bx_param_c::~bx_param_c() -{ - delete [] name; - delete [] label; - delete [] description; - delete [] ask_format; - delete [] group_name; -} - -void bx_param_c::set_description(const char *text) -{ - delete [] this->description; - if (text) { - this->description = new char[strlen(text)+1]; - strcpy(this->description, text); - } else { - this->description = NULL; - } -} - -void bx_param_c::set_label(const char *text) -{ - delete [] label; - if (text) { - label = new char[strlen(text)+1]; - strcpy(label, text); - } else { - label = NULL; - } -} - -void bx_param_c::set_ask_format(const char *format) -{ - delete [] ask_format; - if (format) { - ask_format = new char[strlen(format)+1]; - strcpy(ask_format, format); - } else { - ask_format = NULL; - } -} - -void bx_param_c::set_group(const char *group) -{ - delete [] group_name; - if (group) { - group_name = new char[strlen(group)+1]; - strcpy(group_name, group); - } else { - group_name = NULL; - } -} - -int bx_param_c::get_param_path(char *path_out, int maxlen) -{ - if ((get_parent() == NULL) || (get_parent() == root_param)) { - // Start with an empty string. - // Never print the name of the root param. - path_out[0] = 0; - } else { - // build path of the parent, add a period, add path of this node - if (get_parent()->get_param_path(path_out, maxlen) > 0) { - strncat(path_out, ".", maxlen); - } - } - strncat(path_out, name, maxlen); - return strlen(path_out); -} - -const char* bx_param_c::set_default_format(const char *f) -{ - const char *old = default_text_format; - default_text_format = f; - return old; -} - -bx_param_num_c::bx_param_num_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - Bit64s min, Bit64s max, Bit64s initial_val, - bx_bool is_shadow) - : bx_param_c(SIM->gen_param_id(), name, label, description) -{ - set_type(BXT_PARAM_NUM); - this->min = min; - this->max = max; - this->initial_val = initial_val; - this->val.number = initial_val; - this->handler = NULL; - this->save_handler = NULL; - this->restore_handler = NULL; - this->enable_handler = NULL; - this->base = default_base; - this->is_shadow = is_shadow; - if (!is_shadow) { - set(initial_val); - } - if (parent) { - BX_ASSERT(parent->get_type() == BXT_LIST); - this->parent = (bx_list_c *)parent; - this->parent->add(this); - } -} - -Bit32u bx_param_num_c::default_base = BASE_DEC; - -Bit32u bx_param_num_c::set_default_base(Bit32u val) -{ - Bit32u old = default_base; - default_base = val; - return old; -} - -void bx_param_num_c::set_handler(param_event_handler handler) -{ - this->handler = handler; - // now that there's a handler, call set once to run the handler immediately - //set (get ()); -} - -void bx_param_num_c::set_sr_handlers(void *devptr, param_save_handler save, param_restore_handler restore) -{ - sr_devptr = devptr; - save_handler = save; - restore_handler = restore; -} - -void bx_param_num_c::set_dependent_list(bx_list_c *l) -{ - dependent_list = l; - update_dependents(); -} - -Bit64s bx_param_num_c::get64() -{ - if (save_handler) { - return (*save_handler)(sr_devptr, this); - } - if (handler) { - // the handler can decide what value to return and/or do some side effect - return (*handler)(this, 0, val.number); - } else { - // just return the value - return val.number; - } -} - -void bx_param_num_c::set(Bit64s newval) -{ - if (handler) { - // the handler can override the new value and/or perform some side effect - val.number = newval; - (*handler)(this, 1, newval); - } else { - // just set the value. This code does not check max/min. - val.number = newval; - } - if (restore_handler) { - val.number = newval; - (*restore_handler)(sr_devptr, this, newval); - } - if ((val.number < min || val.number > max) && (Bit64u)max != BX_MAX_BIT64U) - BX_PANIC(("numerical parameter '%s' was set to " FMT_LL "d, which is out of range " FMT_LL "d to " FMT_LL "d", get_name (), val.number, min, max)); - if (dependent_list != NULL) update_dependents(); -} - -void bx_param_num_c::set_range(Bit64u min, Bit64u max) -{ - this->min = min; - this->max = max; -} - -void bx_param_num_c::set_initial_val(Bit64s initial_val) -{ - this->val.number = this->initial_val = initial_val; -} - -void bx_param_num_c::update_dependents() -{ - if (dependent_list) { - int en = val.number && enabled; - for (int i=0; iget_size(); i++) { - bx_param_c *param = dependent_list->get(i); - if (param != this) - param->set_enabled(en); - } - } -} - -void bx_param_num_c::set_enabled(int en) -{ - // The enable handler may wish to allow/disallow the action - if (enable_handler) { - en = (*enable_handler)(this, en); - } - bx_param_c::set_enabled(en); - update_dependents(); -} - -// Signed 64 bit -bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit64s *ptr_to_real_val, - int base, - Bit8u highbit, - Bit8u lowbit) -: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT64S, BX_MAX_BIT64S, *ptr_to_real_val, 1) -{ - this->varsize = 64; - this->lowbit = lowbit; - this->mask = ((BX_MAX_BIT64S >> (63 - (highbit - lowbit))) << lowbit); - val.p64bit = ptr_to_real_val; - if (base == BASE_HEX) { - this->base = base; - this->text_format = "0x"FMT_LL"x"; - } -} - -// Unsigned 64 bit -bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit64u *ptr_to_real_val, - int base, - Bit8u highbit, - Bit8u lowbit) -: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT64U, BX_MAX_BIT64U, *ptr_to_real_val, 1) -{ - this->varsize = 64; - this->lowbit = lowbit; - this->mask = ((BX_MAX_BIT64U >> (63 - (highbit - lowbit))) << lowbit); - val.p64bit = (Bit64s*) ptr_to_real_val; - if (base == BASE_HEX) { - this->base = base; - this->text_format = "0x"FMT_LL"x"; - } -} - -// Signed 32 bit -bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit32s *ptr_to_real_val, - int base, - Bit8u highbit, - Bit8u lowbit) -: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT32S, BX_MAX_BIT32S, *ptr_to_real_val, 1) -{ - this->varsize = 32; - this->lowbit = lowbit; - this->mask = ((BX_MAX_BIT32S >> (31 - (highbit - lowbit))) << lowbit); - val.p32bit = ptr_to_real_val; - if (base == BASE_HEX) { - this->base = base; - this->text_format = "0x%08x"; - } -} - -// Unsigned 32 bit -bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit32u *ptr_to_real_val, - int base, - Bit8u highbit, - Bit8u lowbit) -: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT32U, BX_MAX_BIT32U, *ptr_to_real_val, 1) -{ - this->varsize = 32; - this->lowbit = lowbit; - this->mask = ((BX_MAX_BIT32U >> (31 - (highbit - lowbit))) << lowbit); - val.p32bit = (Bit32s*) ptr_to_real_val; - if (base == BASE_HEX) { - this->base = base; - this->text_format = "0x%08x"; - } -} - -// Signed 16 bit -bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit16s *ptr_to_real_val, - int base, - Bit8u highbit, - Bit8u lowbit) -: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT16S, BX_MAX_BIT16S, *ptr_to_real_val, 1) -{ - this->varsize = 16; - this->lowbit = lowbit; - this->mask = ((BX_MAX_BIT16S >> (15 - (highbit - lowbit))) << lowbit); - val.p16bit = ptr_to_real_val; - if (base == BASE_HEX) { - this->base = base; - this->text_format = "0x%04x"; - } -} - -// Unsigned 16 bit -bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit16u *ptr_to_real_val, - int base, - Bit8u highbit, - Bit8u lowbit) -: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT16U, BX_MAX_BIT16U, *ptr_to_real_val, 1) -{ - this->varsize = 16; - this->lowbit = lowbit; - this->mask = ((BX_MAX_BIT16U >> (15 - (highbit - lowbit))) << lowbit); - val.p16bit = (Bit16s*) ptr_to_real_val; - if (base == BASE_HEX) { - this->base = base; - this->text_format = "0x%04x"; - } -} - -// Signed 8 bit -bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit8s *ptr_to_real_val, - int base, - Bit8u highbit, - Bit8u lowbit) -: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT8S, BX_MAX_BIT8S, *ptr_to_real_val, 1) -{ - this->varsize = 8; - this->lowbit = lowbit; - this->mask = ((BX_MAX_BIT8S >> (7 - (highbit - lowbit))) << lowbit); - this->mask = (1 << (highbit - lowbit)) - 1; - val.p8bit = ptr_to_real_val; - if (base == BASE_HEX) { - this->base = base; - this->text_format = "0x%02x"; - } -} - -// Unsigned 8 bit -bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit8u *ptr_to_real_val, - int base, - Bit8u highbit, - Bit8u lowbit) -: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT8U, BX_MAX_BIT8U, *ptr_to_real_val, 1) -{ - this->varsize = 8; - this->lowbit = lowbit; - this->mask = ((BX_MAX_BIT8U >> (7 - (highbit - lowbit))) << lowbit); - val.p8bit = (Bit8s*) ptr_to_real_val; - if (base == BASE_HEX) { - this->base = base; - this->text_format = "0x%02x"; - } -} - -Bit64s bx_shadow_num_c::get64() -{ - Bit64u current = 0; - switch (varsize) { - case 8: current = *(val.p8bit); break; - case 16: current = *(val.p16bit); break; - case 32: current = *(val.p32bit); break; - case 64: current = *(val.p64bit); break; - default: BX_PANIC(("unsupported varsize %d", varsize)); - } - current = (current >> lowbit) & mask; - if (handler) { - // the handler can decide what value to return and/or do some side effect - return (*handler)(this, 0, current) & mask; - } else { - // just return the value - return current; - } -} - -void bx_shadow_num_c::set(Bit64s newval) -{ - Bit64u tmp = 0; - if (((newval < min) || (newval > max)) && (min != BX_MIN_BIT64S) && ((Bit64u)max != BX_MAX_BIT64U)) - BX_PANIC(("numerical parameter %s was set to " FMT_LL "d, which is out of range " FMT_LL "d to " FMT_LL "d", get_name (), newval, min, max)); - switch (varsize) { - case 8: - tmp = *(val.p8bit) & ~(mask << lowbit); - tmp |= (newval & mask) << lowbit; - *(val.p8bit) = (Bit8s)tmp; - break; - case 16: - tmp = *(val.p16bit) & ~(mask << lowbit); - tmp |= (newval & mask) << lowbit; - *(val.p16bit) = (Bit16s)tmp; - break; - case 32: - tmp = *(val.p32bit) & ~(mask << lowbit); - tmp |= (newval & mask) << lowbit; - *(val.p32bit) = (Bit32s)tmp; - break; - case 64: - tmp = *(val.p64bit) & ~(mask << lowbit); - tmp |= (newval & mask) << lowbit; - *(val.p64bit) = (Bit64s)tmp; - break; - default: - BX_PANIC(("unsupported varsize %d", varsize)); - } - if (handler) { - // the handler can override the new value and/or perform some side effect - (*handler)(this, 1, tmp); - } -} - -void bx_shadow_num_c::reset() -{ - BX_PANIC(("reset not supported on bx_shadow_num_c yet")); -} - -bx_param_bool_c::bx_param_bool_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - Bit64s initial_val, - bx_bool is_shadow) - : bx_param_num_c(parent, name, label, description, 0, 1, initial_val, is_shadow) -{ - set_type(BXT_PARAM_BOOL); -} - -bx_shadow_bool_c::bx_shadow_bool_c(bx_param_c *parent, - const char *name, - const char *label, - bx_bool *ptr_to_real_val, - Bit8u bitnum) - : bx_param_bool_c(parent, name, label, NULL, (Bit64s) *ptr_to_real_val, 1) -{ - val.pbool = ptr_to_real_val; - this->bitnum = bitnum; -} - -bx_shadow_bool_c::bx_shadow_bool_c(bx_param_c *parent, - const char *name, - bx_bool *ptr_to_real_val, - Bit8u bitnum) - : bx_param_bool_c(parent, name, NULL, NULL, (Bit64s) *ptr_to_real_val, 1) -{ - val.pbool = ptr_to_real_val; - this->bitnum = bitnum; -} - -Bit64s bx_shadow_bool_c::get64() -{ - if (handler) { - // the handler can decide what value to return and/or do some side effect - Bit64s ret = (*handler)(this, 0, (Bit64s) *(val.pbool)); - return (ret>>bitnum) & 1; - } else { - // just return the value - return (*(val.pbool)) & 1; - } -} - -void bx_shadow_bool_c::set(Bit64s newval) -{ - // only change the bitnum bit - Bit64s tmp = (newval&1) << bitnum; - *(val.pbool) &= ~tmp; - *(val.pbool) |= tmp; - if (handler) { - // the handler can override the new value and/or perform some side effect - (*handler)(this, 1, newval&1); - } -} - -bx_param_enum_c::bx_param_enum_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - const char **choices, - Bit64s initial_val, - Bit64s value_base) - : bx_param_num_c(parent, name, label, description, value_base, BX_MAX_BIT64S, initial_val) -{ - set_type(BXT_PARAM_ENUM); - this->choices = choices; - // count number of choices, set max - const char **p = choices; - while (*p != NULL) p++; - this->min = value_base; - // now that the max is known, replace the BX_MAX_BIT64S sent to the parent - // class constructor with the real max. - this->max = value_base + (p - choices - 1); - this->deps_bitmap = NULL; - set(initial_val); -} - -bx_param_enum_c::~bx_param_enum_c() -{ - if (deps_bitmap != NULL) { - free(deps_bitmap); - } -} - - -void bx_param_enum_c::set(Bit64s val) -{ - bx_param_num_c::set(val); - update_dependents(); -} - -int bx_param_enum_c::find_by_name(const char *string) -{ - const char **p; - for (p=&choices[0]; *p; p++) { - if (!strcmp(string, *p)) - return p-choices; - } - return -1; -} - -bx_bool bx_param_enum_c::set_by_name(const char *string) -{ - int n = find_by_name(string); - if (n<0) return 0; - set(n + min); - return 1; -} - -void bx_param_enum_c::set_dependent_list(bx_list_c *l, bx_bool enable_all) -{ - dependent_list = l; - deps_bitmap = (Bit64u*)malloc(sizeof(Bit64u) * (max - min + 1)); - for (int i=0; i<(max-min+1); i++) { - if (enable_all) { - deps_bitmap[i] = (1 << (l->get_size())) - 1; - } else { - deps_bitmap[i] = 0; - } - } - update_dependents(); -} - -void bx_param_enum_c::set_dependent_bitmap(Bit64s value, Bit64u bitmap) -{ - if (deps_bitmap != NULL) { - deps_bitmap[value - min] = bitmap; - } - update_dependents(); -} - -Bit64u bx_param_enum_c::get_dependent_bitmap(Bit64s value) -{ - if (deps_bitmap != NULL) { - return deps_bitmap[value - min]; - } - return 0; -} - -void bx_param_enum_c::update_dependents() -{ - if ((dependent_list != NULL) && (deps_bitmap != NULL)) { - Bit64u en_bmap = deps_bitmap[val.number - min]; - Bit64u mask = 0x1; - for (int i=0; iget_size(); i++) { - int en = (en_bmap & mask) && enabled; - bx_param_c *param = dependent_list->get(i); - if (param != this) - param->set_enabled(en); - mask <<= 1; - } - } -} - -void bx_param_enum_c::set_enabled(int en) -{ - // The enable handler may wish to allow/disallow the action - if (enable_handler) { - en = (*enable_handler)(this, en); - } - bx_param_c::set_enabled(en); - update_dependents(); -} - -bx_param_string_c::bx_param_string_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - const char *initial_val, - int maxsize) - : bx_param_c(SIM->gen_param_id(), name, label, description) -{ - set_type(BXT_PARAM_STRING); - int initial_val_size = strlen(initial_val) + 1; - if (maxsize < 0) { - maxsize = initial_val_size; - } else if (initial_val_size > maxsize) { - initial_val_size = maxsize; - } - this->val = new char[maxsize]; - this->initial_val = new char[maxsize]; - this->handler = NULL; - this->enable_handler = NULL; - this->maxsize = maxsize; - strncpy(this->val, initial_val, initial_val_size); - if (maxsize > initial_val_size) - memset(this->val + initial_val_size, 0, maxsize - initial_val_size); - strncpy(this->initial_val, initial_val, maxsize); - this->options = 0; - set(initial_val); - if (parent) { - BX_ASSERT(parent->get_type() == BXT_LIST); - this->parent = (bx_list_c *)parent; - this->parent->add(this); - } -} - -bx_param_filename_c::bx_param_filename_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - const char *initial_val, - int maxsize) - : bx_param_string_c(parent, name, label, description, initial_val, maxsize) -{ - set_options(IS_FILENAME); - ext = NULL; -} - -bx_param_string_c::~bx_param_string_c() -{ - if (val != NULL) delete [] val; - if (initial_val != NULL) delete [] initial_val; -} - -void bx_param_string_c::reset() -{ - set(initial_val); -} - -void bx_param_string_c::set_handler(param_string_event_handler handler) -{ - this->handler = handler; -} - -void bx_param_string_c::set_enable_handler(param_enable_handler handler) -{ - this->enable_handler = handler; -} - -void bx_param_string_c::update_dependents() -{ - if (dependent_list) { - int en = (strlen(val) > 0) && (strcmp(val, "none")) && enabled; - for (int i=0; iget_size(); i++) { - bx_param_c *param = dependent_list->get(i); - if (param != this) - param->set_enabled(en); - } - } -} - -void bx_param_string_c::set_enabled(int en) -{ - // The enable handler may wish to allow/disallow the action - if (enable_handler) { - en = (*enable_handler)(this, en); - } - bx_param_c::set_enabled(en); - if (dependent_list != NULL) update_dependents(); -} - -void bx_param_string_c::set_dependent_list(bx_list_c *l) -{ - dependent_list = l; - update_dependents(); -} - -Bit32s bx_param_string_c::get(char *buf, int len) -{ - if (options & RAW_BYTES) - memcpy(buf, val, len); - else - strncpy(buf, val, len); - if (handler) { - // the handler can choose to replace the value in val/len. Also its - // return value is passed back as the return value of get. - (*handler)(this, 0, buf, buf, len); - } - return 0; -} - -void bx_param_string_c::set(const char *buf) -{ - char *oldval = new char[maxsize]; - - if (options & RAW_BYTES) { - memcpy(oldval, val, maxsize); - memcpy(val, buf, maxsize); - } else { - strncpy(oldval, val, maxsize); - oldval[maxsize - 1] = 0; - strncpy(val, buf, maxsize); - val[maxsize - 1] = 0; - } - if (handler) { - // the handler can return a different char* to be copied into the value - buf = (*handler)(this, 1, oldval, buf, -1); - } - delete [] oldval; - if (dependent_list != NULL) update_dependents(); -} - -bx_bool bx_param_string_c::equals(const char *buf) -{ - if (options & RAW_BYTES) - return (memcmp(val, buf, maxsize) == 0); - else - return (strncmp(val, buf, maxsize) == 0); -} - -void bx_param_string_c::set_initial_val(const char *buf) -{ - if (options & RAW_BYTES) - memcpy(initial_val, buf, maxsize); - else - strncpy(initial_val, buf, maxsize); - set(initial_val); -} - -bx_shadow_data_c::bx_shadow_data_c(bx_param_c *parent, - const char *name, - Bit8u *ptr_to_data, - Bit32u data_size) - : bx_param_c(SIM->gen_param_id(), name, "") -{ - set_type(BXT_PARAM_DATA); - this->data_ptr = ptr_to_data; - this->data_size = data_size; - if (parent) { - BX_ASSERT(parent->get_type() == BXT_LIST); - this->parent = (bx_list_c *)parent; - this->parent->add(this); - } -} - -bx_list_c::bx_list_c(bx_param_c *parent, int maxsize) - : bx_param_c(SIM->gen_param_id(), "list", "") -{ - set_type(BXT_LIST); - this->size = 0; - this->maxsize = maxsize; - this->list = new bx_param_c* [maxsize]; - this->parent = NULL; - if (parent) { - BX_ASSERT(parent->get_type() == BXT_LIST); - this->parent = (bx_list_c *)parent; - this->parent->add(this); - } - init(""); -} - -bx_list_c::bx_list_c(bx_param_c *parent, const char *name, int maxsize) - : bx_param_c(SIM->gen_param_id(), name, "") -{ - set_type (BXT_LIST); - this->size = 0; - this->maxsize = maxsize; - this->list = new bx_param_c* [maxsize]; - this->parent = NULL; - if (parent) { - BX_ASSERT(parent->get_type() == BXT_LIST); - this->parent = (bx_list_c *)parent; - this->parent->add(this); - } - init(""); -} - -bx_list_c::bx_list_c(bx_param_c *parent, const char *name, const char *title, - int maxsize) - : bx_param_c(SIM->gen_param_id(), name, "") -{ - set_type (BXT_LIST); - this->size = 0; - this->maxsize = maxsize; - this->list = new bx_param_c* [maxsize]; - this->parent = NULL; - if (parent) { - BX_ASSERT(parent->get_type() == BXT_LIST); - this->parent = (bx_list_c *)parent; - this->parent->add(this); - } - init(title); -} - -bx_list_c::bx_list_c(bx_param_c *parent, const char *name, const char *title, bx_param_c **init_list) - : bx_param_c(SIM->gen_param_id(), name, "") -{ - set_type(BXT_LIST); - this->size = 0; - while (init_list[this->size] != NULL) - this->size++; - this->maxsize = this->size; - this->list = new bx_param_c* [maxsize]; - for (int i=0; isize; i++) - this->list[i] = init_list[i]; - this->parent = NULL; - if (parent) { - BX_ASSERT(parent->get_type() == BXT_LIST); - this->parent = (bx_list_c *)parent; - this->parent->add(this); - } - init(title); -} - -bx_list_c::~bx_list_c() -{ - if (list != NULL) { - for (int i=0; ititle = new bx_param_string_c(NULL, - "list_title", - "", "", - get_name(), 80); - if ((list_title != NULL) && (strlen(list_title) > 0)) { - this->title->set((char *)list_title); - } - this->options = 0; - this->choice = new bx_param_num_c(NULL, - "list_choice", "", "", 0, BX_MAX_BIT64S, 1); -} - -void bx_list_c::set_parent(bx_param_c *newparent) -{ - if (parent) { - // if this object already had a parent, the correct thing - // to do would be to remove this object from the parent's - // list of children. Deleting children is currently - // not supported. - BX_PANIC(("bx_list_c::set_parent: changing from one parent to another is not supported")); - } - if (newparent) { - BX_ASSERT(newparent->get_type() == BXT_LIST); - parent = (bx_list_c *)newparent; - parent->add(this); - } -} - -bx_list_c* bx_list_c::clone() -{ - bx_list_c *newlist = new bx_list_c(NULL, name, title->getptr(), maxsize); - for (int i=0; iadd(get(i)); - newlist->set_options(options); - return newlist; -} - -void bx_list_c::add(bx_param_c *param) -{ - if (size >= maxsize) { - BX_PANIC(("add param '%s' to bx_list_c '%s': list capacity exceeded", - param->get_name(), get_name())); - return; - } - list[size] = param; - size++; -} - -bx_param_c* bx_list_c::get(int index) -{ - BX_ASSERT(index >= 0 && index < size); - return list[index]; -} - -bx_param_c* bx_list_c::get_by_name(const char *name) -{ - int imax = get_size(); - for (int i=0; iget_name())) { - return p; - } - } - return NULL; -} - -void bx_list_c::reset() -{ - int imax = get_size(); - for (int i=0; ireset(); - } -} - -void bx_list_c::clear() -{ - int imax = get_size(); - for (int i=0; iget_parent() == this) { - delete param; - } - } - size = 0; -} - -void bx_list_c::remove(const char *name) -{ - int imax = get_size(); - int found = 0; - for (int i=0; iget_name())) { - if (p->get_parent() == this) { - delete p; - } - found = 1; - } - if (found) { - list[i] = list[i+1]; - } - } - if (found) { - size--; - } -} diff --git a/bochs/gui/siminterface.h b/bochs/gui/siminterface.h index 67f9c85e8..5ca219b0c 100644 --- a/bochs/gui/siminterface.h +++ b/bochs/gui/siminterface.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: siminterface.h,v 1.254 2010-09-12 20:47:23 sshwarts Exp $ +// $Id: siminterface.h,v 1.255 2010-09-16 21:46:45 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2009 The Bochs Project @@ -436,444 +436,7 @@ typedef struct { } u; } BxEvent; - -//////////////////////////////////////////////////////////////////// -// parameter classes: bx_param_c and family -//////////////////////////////////////////////////////////////////// -// -// All variables that can be configured through the CI are declared as -// "parameters" or objects of type bx_param_*. There is a bx_param_* -// class for each type of data that the user would need to see and -// edit, e.g. integer, boolean, enum, string, filename, or list of -// other parameters. The purpose of the bx_param_* class, in addition -// to storing the parameter's value, is to hold the name, description, -// and constraints on the value. The bx_param_* class should hold -// everything that the CI would need to display the value and allow -// the user to modify it. For integer parameters, the minimum and -// maximum allowed value can be defined, and the base in which it -// should be displayed and interpreted. For enums, the -// bx_param_enum_c structure includes the list of values which the -// parameter can have. -// -// Also, some parameter classes support get/set callback functions to -// allow arbitrary code to be executed when the parameter is get/set. -// An example of where this is useful: if you disable the NE2K card, -// the set() handler for that parameter can tell the user interface -// that the NE2K's irq, I/O address, and mac address should be -// disabled (greyed out, hidden, or made inaccessible). The get/set -// methods can also check if the set() value is acceptable using -// whatever means and override it. -// -// The parameter concept is similar to the use of parameters in JavaBeans. - -class bx_object_c; -class bx_param_c; -class bx_param_num_c; -class bx_param_enum_c; -class bx_param_bool_c; -class bx_param_string_c; -class bx_param_filename_c; -class bx_list_c; - -class BOCHSAPI bx_object_c { -private: - Bit32u id; - bx_objtype type; -protected: - void set_type(bx_objtype _type) { type = _type; } -public: - bx_object_c(Bit32u _id): id(_id), type(BXT_OBJECT) {} - virtual ~bx_object_c() {} - Bit32u get_id() const { return id; } - Bit8u get_type() const { return type; } -}; - -#define BASE_DEC 10 -#define BASE_HEX 16 - -class BOCHSAPI bx_param_c : public bx_object_c { - BOCHSAPI_CYGONLY static const char *default_text_format; -protected: - bx_list_c *parent; - char *name; - char *description; - char *label; // label string for text menus and gui dialogs - const char *text_format; // printf format string. %d for ints, %s for strings, etc. - const char *long_text_format; // printf format string. %d for ints, %s for strings, etc. - char *ask_format; // format string for asking for a new value - char *group_name; // name of the group the param belongs to - int runtime_param; - int enabled; - Bit32u options; - // The dependent_list is initialized to NULL. If dependent_list is modified - // to point to a bx_list_c of other parameters, the set() method of the - // parameter type will enable those parameters when the enable condition is - // true, and disable them it is false. - bx_list_c *dependent_list; - void *device; -public: - bx_param_c(Bit32u id, const char *name, const char *description); - bx_param_c(Bit32u id, const char *name, const char *label, const char *description); - virtual ~bx_param_c(); - bx_param_c *get_parent() { return (bx_param_c *) parent; } - int get_param_path(char *path_out, int maxlen); - void set_format(const char *format) {text_format = format;} - const char *get_format() const {return text_format;} - void set_long_format(const char *format) {long_text_format = format;} - const char *get_long_format() const {return long_text_format;} - void set_ask_format(const char *format); - const char *get_ask_format() const {return ask_format;} - void set_label(const char *text); - void set_description(const char *text); - const char *get_label() const {return label;} - void set_runtime_param(int val) { runtime_param = val; } - int get_runtime_param() { return runtime_param; } - void set_group(const char *group); - const char *get_group() const {return group_name;} - const char *get_name() const { return name; } - const char *get_description() const { return description; } - int get_enabled() const { return enabled; } - virtual void set_enabled(int enabled) { this->enabled = enabled; } - virtual void reset() {} - int getint() const {return -1;} - static const char* set_default_format(const char *f); - static const char *get_default_format() { return default_text_format; } - bx_list_c *get_dependent_list() { return dependent_list; } - void set_options(Bit32u options) { this->options = options; } - Bit32u get_options() const { return options; } - void set_device_param(void *dev) { device = dev; } - void *get_device_param() { return device; } -#if BX_USE_TEXTCONFIG - virtual void text_print(FILE *fp) {} - virtual int text_ask(FILE *fpin, FILE *fpout) {return -1;} -#endif -}; - -typedef Bit64s (*param_event_handler)(class bx_param_c *, int set, Bit64s val); -typedef Bit64s (*param_save_handler)(void *devptr, class bx_param_c *); -typedef void (*param_restore_handler)(void *devptr, class bx_param_c *, Bit64s val); -typedef int (*param_enable_handler)(class bx_param_c *, int en); - -class BOCHSAPI bx_param_num_c : public bx_param_c { - BOCHSAPI_CYGONLY static Bit32u default_base; - void update_dependents(); -protected: - Bit64s min, max, initial_val; - union _uval_ { - Bit64s number; // used by bx_param_num_c - Bit64s *p64bit; // used by bx_shadow_num_c - Bit32s *p32bit; // used by bx_shadow_num_c - Bit16s *p16bit; // used by bx_shadow_num_c - Bit8s *p8bit; // used by bx_shadow_num_c - bx_bool *pbool; // used by bx_shadow_bool_c - } val; - param_event_handler handler; - void *sr_devptr; - param_save_handler save_handler; - param_restore_handler restore_handler; - param_enable_handler enable_handler; - int base; - bx_bool is_shadow; -public: - enum { - // When a bx_param_num_c is displayed in dialog, USE_SPIN_CONTROL controls - // whether a spin control should be used instead of a simple text control. - USE_SPIN_CONTROL = (1<<0) - } bx_numopt_bits; - bx_param_num_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - Bit64s min, Bit64s max, Bit64s initial_val, - bx_bool is_shadow = 0); - virtual void reset() { val.number = initial_val; } - void set_handler(param_event_handler handler); - void set_sr_handlers(void *devptr, param_save_handler save, param_restore_handler restore); - void set_enable_handler(param_enable_handler handler) { enable_handler = handler; } - void set_dependent_list(bx_list_c *l); - virtual void set_enabled(int enabled); - virtual Bit32s get() { return (Bit32s) get64(); } - virtual Bit64s get64(); - virtual void set(Bit64s val); - void set_base(int base) { this->base = base; } - void set_initial_val(Bit64s initial_val); - int get_base() const { return base; } - void set_range(Bit64u min, Bit64u max); - Bit64s get_min() { return min; } - Bit64s get_max() { return max; } - static Bit32u set_default_base(Bit32u val); - static Bit32u get_default_base() { return default_base; } -#if BX_USE_TEXTCONFIG - virtual void text_print(FILE *fp); - virtual int text_ask(FILE *fpin, FILE *fpout); -#endif -}; - -// a bx_shadow_num_c is like a bx_param_num_c except that it doesn't -// store the actual value with its data. Instead, it uses val.p32bit -// to keep a pointer to the actual data. This is used to register -// existing variables as parameters, without having to access it via -// set/get methods. -class BOCHSAPI bx_shadow_num_c : public bx_param_num_c { - Bit8u varsize; // must be 64, 32, 16, or 8 - Bit8u lowbit; // range of bits associated with this param - Bit64u mask; // mask is ANDed with value before it is returned from get -public: - bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit64s *ptr_to_real_val, - int base = BASE_DEC, - Bit8u highbit = 63, - Bit8u lowbit = 0); - bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit64u *ptr_to_real_val, - int base = BASE_DEC, - Bit8u highbit = 63, - Bit8u lowbit = 0); - bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit32s *ptr_to_real_val, - int base = BASE_DEC, - Bit8u highbit = 31, - Bit8u lowbit = 0); - bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit32u *ptr_to_real_val, - int base = BASE_DEC, - Bit8u highbit = 31, - Bit8u lowbit = 0); - bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit16s *ptr_to_real_val, - int base = BASE_DEC, - Bit8u highbit = 15, - Bit8u lowbit = 0); - bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit16u *ptr_to_real_val, - int base = BASE_DEC, - Bit8u highbit = 15, - Bit8u lowbit = 0); - bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit8s *ptr_to_real_val, - int base = BASE_DEC, - Bit8u highbit = 7, - Bit8u lowbit = 0); - bx_shadow_num_c(bx_param_c *parent, - const char *name, - Bit8u *ptr_to_real_val, - int base = BASE_DEC, - Bit8u highbit = 7, - Bit8u lowbit = 0); - virtual Bit64s get64(); - virtual void set(Bit64s val); - virtual void reset(); -}; - -class BOCHSAPI bx_param_bool_c : public bx_param_num_c { - // many boolean variables are used to enable/disable modules. In the - // user interface, the enable variable should enable/disable all the - // other parameters associated with that module. -public: - bx_param_bool_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - Bit64s initial_val, - bx_bool is_shadow = 0); -#if BX_USE_TEXTCONFIG - virtual void text_print(FILE *fp); - virtual int text_ask(FILE *fpin, FILE *fpout); -#endif -}; - -// a bx_shadow_bool_c is a shadow param based on bx_param_bool_c. -class BOCHSAPI bx_shadow_bool_c : public bx_param_bool_c { - // each bit of a bitfield can be a separate value. bitnum tells which - // bit is used. get/set will only modify that bit. - Bit8u bitnum; -public: - bx_shadow_bool_c(bx_param_c *parent, - const char *name, - const char *label, - bx_bool *ptr_to_real_val, - Bit8u bitnum = 0); - bx_shadow_bool_c(bx_param_c *parent, - const char *name, - bx_bool *ptr_to_real_val, - Bit8u bitnum = 0); - virtual Bit64s get64(); - virtual void set(Bit64s val); -}; - - -class BOCHSAPI bx_param_enum_c : public bx_param_num_c { - const char **choices; - Bit64u *deps_bitmap; - void update_dependents(); -public: - bx_param_enum_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - const char **choices, - Bit64s initial_val, - Bit64s value_base = 0); - virtual ~bx_param_enum_c(); - const char *get_choice(int n) { return choices[n]; } - const char *get_selected() { return choices[val.number - min]; } - int find_by_name(const char *string); - virtual void set(Bit64s val); - bx_bool set_by_name(const char *string); - void set_dependent_list(bx_list_c *l, bx_bool enable_all); - void set_dependent_bitmap(Bit64s value, Bit64u bitmap); - Bit64u get_dependent_bitmap(Bit64s value); - virtual void set_enabled(int enabled); -#if BX_USE_TEXTCONFIG - virtual void text_print(FILE *fp); - virtual int text_ask(FILE *fpin, FILE *fpout); -#endif -}; - -typedef const char* (*param_string_event_handler)(class bx_param_string_c *, - int set, const char *oldval, const char *newval, int maxlen); - -class BOCHSAPI bx_param_string_c : public bx_param_c { - int maxsize; - char *val, *initial_val; - param_string_event_handler handler; - param_enable_handler enable_handler; - char separator; - void update_dependents(); -public: - enum { - RAW_BYTES = 1, // use binary text editor, like MAC addr - IS_FILENAME = 2, // 1=yes it's a filename, 0=not a filename. - // Some guis have a file browser. This - // bit suggests that they use it. - SAVE_FILE_DIALOG = 4, // Use save dialog opposed to open file dialog - SELECT_FOLDER_DLG = 8 // Use folder selection dialog - } bx_string_opt_bits; - bx_param_string_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - const char *initial_val, - int maxsize=-1); - virtual ~bx_param_string_c(); - virtual void reset(); - void set_handler(param_string_event_handler handler); - void set_enable_handler(param_enable_handler handler); - virtual void set_enabled(int enabled); - void set_dependent_list(bx_list_c *l); - Bit32s get(char *buf, int len); - char *getptr() {return val; } - void set(const char *buf); - bx_bool equals(const char *buf); - void set_separator(char sep) {separator = sep; } - char get_separator() const {return separator; } - int get_maxsize() const {return maxsize; } - void set_initial_val(const char *buf); -#if BX_USE_TEXTCONFIG - virtual void text_print(FILE *fp); - virtual int text_ask(FILE *fpin, FILE *fpout); -#endif -}; - -// Declare a filename class. It is identical to a string, except that -// it initializes the options differently. This is just a shortcut -// for declaring a string param and setting the options with IS_FILENAME. -class BOCHSAPI bx_param_filename_c : public bx_param_string_c { -const char *ext; -public: - bx_param_filename_c(bx_param_c *parent, - const char *name, - const char *label, - const char *description, - const char *initial_val, - int maxsize=-1); - const char *get_extension() {return ext;} - void set_extension(const char *ext) {this->ext = ext;} -}; - -class BOCHSAPI bx_shadow_data_c : public bx_param_c { - Bit32u data_size; - Bit8u *data_ptr; -public: - bx_shadow_data_c(bx_param_c *parent, - const char *name, - Bit8u *ptr_to_data, - Bit32u data_size); - Bit8u *getptr() {return data_ptr;} - Bit32u get_size() const {return data_size;} -}; - -#define BX_DEFAULT_LIST_SIZE 6 - -class BOCHSAPI bx_list_c : public bx_param_c { -protected: - // just a list of bx_param_c objects. size tells current number of - // objects in the list, and maxsize tells how many list items are - // allocated in the constructor. - bx_param_c **list; - int size, maxsize; - // for a menu, the value of choice before the call to "ask" is default. - // After ask, choice holds the value that the user chose. Choice defaults - // to 1 in the constructor. - bx_param_num_c *choice; - // title of the menu or series - bx_param_string_c *title; - void init(const char *list_title); -public: - enum { - // When a bx_list_c is displayed as a menu, SHOW_PARENT controls whether or - // not the menu shows a "Return to parent menu" choice or not. - SHOW_PARENT = (1<<0), - // Some lists are best displayed shown as menus, others as a series of - // related questions. This bit suggests to the CI that the series of - // questions format is preferred. - SERIES_ASK = (1<<1), - // When a bx_list_c is displayed in a dialog, USE_TAB_WINDOW suggests - // to the CI that each item in the list should be shown as a separate - // tab. This would be most appropriate when each item is another list - // of parameters. - USE_TAB_WINDOW = (1<<2), - // When a bx_list_c is displayed in a dialog, the list name is used as the - // label of the group box if USE_BOX_TITLE is set. This is only necessary if - // more than one list appears in a dialog box. - USE_BOX_TITLE = (1<<3), - // When a bx_list_c is displayed as a menu, SHOW_GROUP_NAME controls whether - // or not the name of group the item belongs to is added to the name of the - // item (used in the runtime menu). - SHOW_GROUP_NAME = (1<<4) - } bx_listopt_bits; - bx_list_c(bx_param_c *parent, int maxsize); - bx_list_c(bx_param_c *parent, const char *name, int maxsize); - bx_list_c(bx_param_c *parent, const char *name, const char *title, int maxsize = BX_DEFAULT_LIST_SIZE); - bx_list_c(bx_param_c *parent, const char *name, const char *title, bx_param_c **init_list); - virtual ~bx_list_c(); - bx_list_c *clone(); - void add(bx_param_c *param); - bx_param_c *get(int index); - bx_param_c *get_by_name(const char *name); - int get_size() const { return size; } - bx_param_num_c *get_choice() { return choice; } - bx_param_string_c *get_title() { return title; } - void set_parent(bx_param_c *newparent); - bx_param_c *get_parent() { return parent; } - virtual void reset(); - virtual void clear(); - virtual void remove(const char *name); -#if BX_USE_TEXTCONFIG - virtual void text_print(FILE *); - virtual int text_ask(FILE *fpin, FILE *fpout); -#endif -}; - -//////////////////////////////////////////////////////////////// - +#include "paramtree.h" // These are the different start modes. enum {