- some more work for the save/restore feature in the plugins and devices code
* register_state() will be called after init() and registers the device members required for save/restore * before_save_state() can do some work before the device state is saved by the siminterface * after_restore_state() can do some work after the device state has been restored (updating dependant stuff)
This commit is contained in:
parent
14107f56fa
commit
36498746c1
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.cc,v 1.141 2006-04-15 14:05:18 vruppert Exp $
|
||||
// $Id: siminterface.cc,v 1.142 2006-04-15 17:03:59 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// See siminterface.h for description of the siminterface concept.
|
||||
@ -864,6 +864,7 @@ bx_bool bx_real_sim_c::save_state(const char *checkpoint_path)
|
||||
int type, ntype = SIM->get_max_log_level();
|
||||
FILE *fp;
|
||||
|
||||
DEV_before_save_state();
|
||||
sprintf(sr_file, "%s/config", checkpoint_path);
|
||||
write_rc(sr_file, 1);
|
||||
sprintf(sr_file, "%s/logopts", checkpoint_path);
|
||||
@ -1056,7 +1057,6 @@ bx_bool bx_real_sim_c::restore_hardware()
|
||||
BX_ERROR(("restore_hardware(): unknown parameter type"));
|
||||
}
|
||||
}
|
||||
printf("%d: %s\n", i, ptr);
|
||||
i++;
|
||||
ptr = strtok(NULL, " ");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: devices.cc,v 1.97 2006-04-05 18:49:32 sshwarts Exp $
|
||||
// $Id: devices.cc,v 1.98 2006-04-15 17:03:59 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -105,7 +105,7 @@ void bx_devices_c::init(BX_MEM_C *newmem)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
BX_DEBUG(("Init $Id: devices.cc,v 1.97 2006-04-05 18:49:32 sshwarts Exp $"));
|
||||
BX_DEBUG(("Init $Id: devices.cc,v 1.98 2006-04-15 17:03:59 vruppert Exp $"));
|
||||
mem = newmem;
|
||||
|
||||
/* set no-default handlers, will be overwritten by the real default handler */
|
||||
@ -319,13 +319,13 @@ void bx_devices_c::reset(unsigned type)
|
||||
mem->disable_smram();
|
||||
pluginUnmapped->reset(type);
|
||||
#if BX_SUPPORT_PCI
|
||||
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get ()) {
|
||||
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
|
||||
pluginPciBridge->reset(type);
|
||||
pluginPci2IsaBridge->reset(type);
|
||||
}
|
||||
#endif
|
||||
#if BX_SUPPORT_IOAPIC
|
||||
ioapic->reset (type);
|
||||
#if BX_SUPPORT_APIC
|
||||
ioapic->reset(type);
|
||||
#endif
|
||||
pluginBiosDevice->reset(type);
|
||||
pluginCmosDevice->reset(type);
|
||||
@ -341,6 +341,46 @@ void bx_devices_c::reset(unsigned type)
|
||||
bx_reset_plugins(type);
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
void bx_devices_c::register_state()
|
||||
{
|
||||
pluginUnmapped->register_state();
|
||||
#if BX_SUPPORT_PCI
|
||||
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
|
||||
pluginPciBridge->register_state();
|
||||
pluginPci2IsaBridge->register_state();
|
||||
}
|
||||
#endif
|
||||
#if BX_SUPPORT_APIC
|
||||
//ioapic->register_state();
|
||||
#endif
|
||||
pluginBiosDevice->register_state();
|
||||
pluginCmosDevice->register_state();
|
||||
pluginDmaDevice->register_state();
|
||||
pluginFloppyDevice->register_state();
|
||||
pluginVgaDevice->register_state();
|
||||
pluginPicDevice->register_state();
|
||||
//pit->register_state();
|
||||
#if BX_SUPPORT_IODEBUG
|
||||
iodebug->register_state();
|
||||
#endif
|
||||
// now register state of optional plugins
|
||||
bx_plugins_register_state();
|
||||
}
|
||||
|
||||
void bx_devices_c::before_save_state()
|
||||
{
|
||||
// TODO
|
||||
bx_plugins_before_save_state();
|
||||
}
|
||||
|
||||
void bx_devices_c::after_restore_state()
|
||||
{
|
||||
// TODO
|
||||
bx_plugins_after_restore_state();
|
||||
}
|
||||
#endif
|
||||
|
||||
Bit32u bx_devices_c::read_handler(void *this_ptr, Bit32u address, unsigned io_len)
|
||||
{
|
||||
#if !BX_USE_DEV_SMF
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: iodev.h,v 1.73 2006-03-08 19:28:36 sshwarts Exp $
|
||||
// $Id: iodev.h,v 1.74 2006-04-15 17:03:59 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -85,8 +85,11 @@ class BOCHSAPI bx_devmodel_c : public logfunctions {
|
||||
virtual void init_mem(BX_MEM_C *) {}
|
||||
virtual void init(void) {}
|
||||
virtual void reset(unsigned type) {}
|
||||
virtual void device_load_state () {}
|
||||
virtual void device_save_state () {}
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
virtual void register_state(void) {}
|
||||
virtual void before_save_state(void) {}
|
||||
virtual void after_restore_state(void) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -387,6 +390,11 @@ public:
|
||||
// The types of reset conditions are defined in bochs.h:
|
||||
// power-on, hardware, or software.
|
||||
void reset(unsigned type);
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
void register_state(void);
|
||||
void before_save_state(void);
|
||||
void after_restore_state(void);
|
||||
#endif
|
||||
BX_MEM_C *mem; // address space associated with these devices
|
||||
bx_bool register_io_read_handler(void *this_ptr, bx_read_handler_t f,
|
||||
Bit32u addr, const char *name, Bit8u mask );
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: main.cc,v 1.330 2006-04-09 13:55:53 vruppert Exp $
|
||||
// $Id: main.cc,v 1.331 2006-04-15 17:03:59 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -1003,6 +1003,7 @@ int bx_init_hardware()
|
||||
|
||||
DEV_init_devices();
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
DEV_register_state();
|
||||
if (SIM->get_param_bool(BXPN_RESTORE_FLAG)->get()) {
|
||||
SIM->restore_logopts();
|
||||
}
|
||||
@ -1012,6 +1013,7 @@ int bx_init_hardware()
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
if (SIM->get_param_bool(BXPN_RESTORE_FLAG)->get()) {
|
||||
// SIM->restore_hardware();
|
||||
// DEV_after_restore_state();
|
||||
}
|
||||
#endif
|
||||
bx_gui->init_signal_handlers();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: plugin.cc,v 1.16 2006-04-14 13:27:17 vruppert Exp $
|
||||
// $Id: plugin.cc,v 1.17 2006-04-15 17:03:59 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This file defines the plugin and plugin-device registration functions and
|
||||
@ -607,4 +607,46 @@ void bx_reset_plugins(unsigned signal)
|
||||
}
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
/**************************************************************************/
|
||||
/* Plugin system: Register device state of all registered plugin-devices */
|
||||
/**************************************************************************/
|
||||
|
||||
void bx_plugins_register_state()
|
||||
{
|
||||
device_t *device;
|
||||
for (device = devices; device; device = device->next)
|
||||
{
|
||||
pluginlog->info("register state of '%s' plugin device by virtual method",device->name);
|
||||
device->devmodel->register_state();
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/* Plugin system: Execute code before saving state of all plugin devices */
|
||||
/**************************************************************************/
|
||||
|
||||
void bx_plugins_before_save_state()
|
||||
{
|
||||
device_t *device;
|
||||
for (device = devices; device; device = device->next)
|
||||
{
|
||||
device->devmodel->before_save_state();
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* Plugin system: Execute code after restoring state of all plugin devices */
|
||||
/***************************************************************************/
|
||||
|
||||
void bx_plugins_after_restore_state()
|
||||
{
|
||||
device_t *device;
|
||||
for (device = devices; device; device = device->next)
|
||||
{
|
||||
device->devmodel->after_restore_state();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: plugin.h,v 1.50 2006-03-07 21:11:12 sshwarts Exp $
|
||||
// $Id: plugin.h,v 1.51 2006-04-15 17:03:59 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This file provides macros and types needed for plugins. It is based on
|
||||
@ -53,6 +53,9 @@ extern "C" {
|
||||
|
||||
#define DEV_init_devices() {bx_devices.init(BX_MEM(0)); }
|
||||
#define DEV_reset_devices(type) {bx_devices.reset(type); }
|
||||
#define DEV_register_state() {bx_devices.register_state(); }
|
||||
#define DEV_before_save_state() {bx_devices.before_save_state(); }
|
||||
#define DEV_after_restore_state() {bx_devices.after_restore_state(); }
|
||||
#define PLUG_load_plugin(name,type) {bx_load_plugin(#name,type);}
|
||||
|
||||
#define DEV_register_ioread_handler(b,c,d,e,f) pluginRegisterIOReadHandler(b,c,d,e,f)
|
||||
@ -73,6 +76,9 @@ extern "C" {
|
||||
|
||||
#define DEV_init_devices() {bx_devices.init(BX_MEM(0)); }
|
||||
#define DEV_reset_devices(type) {bx_devices.reset(type); }
|
||||
#define DEV_register_state() {bx_devices.register_state(); }
|
||||
#define DEV_before_save_state() {bx_devices.before_save_state(); }
|
||||
#define DEV_after_restore_state() {bx_devices.after_restore_state(); }
|
||||
// When plugins are off, PLUG_load_plugin will call the plugin_init function
|
||||
// directly.
|
||||
#define PLUG_load_plugin(name,type) {lib##name##_LTX_plugin_init(NULL,type,0,NULL);}
|
||||
@ -259,8 +265,6 @@ void plugin_fini_all (void);
|
||||
typedef void (*deviceInitMem_t)(BX_MEM_C *);
|
||||
typedef void (*deviceInitDev_t)(void);
|
||||
typedef void (*deviceReset_t)(unsigned);
|
||||
typedef void (*deviceLoad_t)(void);
|
||||
typedef void (*deviceSave_t)(void);
|
||||
|
||||
BOCHSAPI void pluginRegisterDeviceDevmodel(plugin_t *plugin, plugintype_t type, bx_devmodel_c *dev, char *name);
|
||||
BOCHSAPI bx_bool pluginDevicePresent(char *name);
|
||||
@ -330,11 +334,16 @@ BOCHSAPI extern bx_bool (*pluginRegisterPCIDevice)(void *this_ptr,
|
||||
BOCHSAPI extern Bit8u (*pluginRd_memType)(Bit32u addr);
|
||||
BOCHSAPI extern Bit8u (*pluginWr_memType)(Bit32u addr);
|
||||
|
||||
void plugin_abort (void);
|
||||
void plugin_abort(void);
|
||||
|
||||
int bx_load_plugin (const char *name, plugintype_t type);
|
||||
extern void bx_init_plugins (void);
|
||||
extern void bx_reset_plugins (unsigned);
|
||||
int bx_load_plugin(const char *name, plugintype_t type);
|
||||
extern void bx_init_plugins(void);
|
||||
extern void bx_reset_plugins(unsigned);
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
extern void bx_plugins_register_state();
|
||||
extern void bx_plugins_before_save_state();
|
||||
extern void bx_plugins_after_restore_state();
|
||||
#endif
|
||||
|
||||
// every plugin must define these, within the extern"C" block, so that
|
||||
// a non-mangled function symbol is available in the shared library.
|
||||
|
Loading…
Reference in New Issue
Block a user