diff --git a/bochs/iodev/Makefile.in b/bochs/iodev/Makefile.in index 341380cce..c3f22ccf4 100644 --- a/bochs/iodev/Makefile.in +++ b/bochs/iodev/Makefile.in @@ -72,7 +72,6 @@ OBJS_THAT_CANNOT_BE_PLUGINS = \ pit82c54.o pit_wrap.o \ virt_timer.o \ slowdown_timer.o \ - @IODEBUG_OBJS@ \ $(MCH_OBJS) \ $(IOAPIC_OBJS) @@ -94,7 +93,8 @@ OBJS_THAT_CAN_BE_PLUGINS = \ @GAME_OBJS@ \ @PCI_OBJ@ \ @SB16_OBJS@ \ - @NE2K_OBJS@ + @NE2K_OBJS@ \ + @IODEBUG_OBJS@ OBJS_THAT_SUPPORT_OTHER_PLUGINS = \ scancodes.o \ diff --git a/bochs/iodev/devices.cc b/bochs/iodev/devices.cc index 12d94de12..45f82991c 100644 --- a/bochs/iodev/devices.cc +++ b/bochs/iodev/devices.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: devices.cc,v 1.125 2008-12-29 20:16:07 sshwarts Exp $ +// $Id: devices.cc,v 1.126 2008-12-30 18:11:13 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -102,7 +102,7 @@ void bx_devices_c::init_stubs() pluginBusMouse = &stubBusMouse; #endif #if BX_SUPPORT_IODEBUG - iodebug = NULL; + pluginIODebug = &stubIODebug; #endif #if 0 g2h = NULL; @@ -114,7 +114,7 @@ void bx_devices_c::init(BX_MEM_C *newmem) unsigned i; const char def_name[] = "Default"; - BX_DEBUG(("Init $Id: devices.cc,v 1.125 2008-12-29 20:16:07 sshwarts Exp $")); + BX_DEBUG(("Init $Id: devices.cc,v 1.126 2008-12-30 18:11:13 vruppert Exp $")); mem = newmem; /* set no-default handlers, will be overwritten by the real default handler */ @@ -251,6 +251,9 @@ void bx_devices_c::init(BX_MEM_C *newmem) BX_ERROR(("Bochs is not compiled with SB16 support")); #endif } +#if BX_SUPPORT_IODEBUG + PLUG_load_plugin(iodebug, PLUGTYPE_OPTIONAL); +#endif #if BX_SUPPORT_PCI pluginPciBridge->init (); @@ -267,11 +270,6 @@ void bx_devices_c::init(BX_MEM_C *newmem) pit = & bx_pit; pit->init(); -#if BX_SUPPORT_IODEBUG - iodebug = &bx_iodebug; - iodebug->init(); -#endif - #if 0 // Guest to Host interface. Used with special guest drivers // which move data to/from the host environment. @@ -337,9 +335,6 @@ void bx_devices_c::reset(unsigned type) pluginVgaDevice->reset(type); pluginPicDevice->reset(type); pit->reset(type); -#if BX_SUPPORT_IODEBUG - iodebug->reset(type); -#endif // now reset optional plugins bx_reset_plugins(type); } diff --git a/bochs/iodev/iodebug.cc b/bochs/iodev/iodebug.cc index 670914556..c4b845e8d 100644 --- a/bochs/iodev/iodebug.cc +++ b/bochs/iodev/iodebug.cc @@ -1,15 +1,57 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: iodebug.cc,v 1.26 2008-05-01 20:46:58 sshwarts Exp $ +// $Id: iodebug.cc,v 1.27 2008-12-30 18:11:13 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2008 MandrakeSoft S.A. +// +// MandrakeSoft S.A. +// 43, rue d'Aboukir +// 75002 Paris - France +// http://www.linux-mandrake.com/ +// http://www.mandrakesoft.com/ +// +// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +///////////////////////////////////////////////////////////////////////// + +// Define BX_PLUGGABLE in files that can be compiled into plugins. For +// platforms that require a special tag on exported symbols, BX_PLUGGABLE +// is used to know when we are exporting symbols and when we are importing. +#define BX_PLUGGABLE #include "bochs.h" #include "cpu/cpu.h" #include "iodev.h" #if BX_SUPPORT_IODEBUG +#include "iodebug.h" #define BX_IODEBUG_THIS this-> -bx_iodebug_c bx_iodebug; +bx_iodebug_c *theIODebugDevice = NULL; + +int libiodebug_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[]) +{ + theIODebugDevice = new bx_iodebug_c(); + bx_devices.pluginIODebug = theIODebugDevice; + BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theIODebugDevice, BX_PLUGIN_IODEBUG); + return(0); // Success +} + +void libiodebug_LTX_plugin_fini(void) +{ + delete theIODebugDevice; +} struct bx_iodebug_s_type { bx_bool enabled; @@ -167,12 +209,12 @@ void bx_iodebug_c::mem_write(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, v if (cpu != NULL) fprintf(stderr, "by EIP:\t\t" FMT_ADDRX "\n\t", cpu->get_instruction_pointer()); else - fprintf(stderr, "(device origin)\t", cpu->get_instruction_pointer()); + fprintf(stderr, "(device origin)\t"); fprintf(stderr, "range start: \t\t%08X\trange end:\t%08X\n\taddress accessed:\t%08X\tdata written:\t", - bx_iodebug_s.monitored_mem_areas_start[area], - bx_iodebug_s.monitored_mem_areas_end[area], - (unsigned) addr); + bx_iodebug_s.monitored_mem_areas_start[area], + bx_iodebug_s.monitored_mem_areas_end[area], + (unsigned) addr); switch(len) { @@ -230,7 +272,7 @@ void bx_iodebug_c::mem_read(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, vo if (cpu != NULL) fprintf(stderr, "by EIP:\t\t" FMT_ADDRX "\n\t", cpu->get_instruction_pointer()); else - fprintf(stderr, "(device origin)\t", cpu->get_instruction_pointer()); + fprintf(stderr, "(device origin)\t"); fprintf(stderr, "range start: \t\t%08X\trange end:\t%08X\n\taddress accessed:\t%08X\tdata written:\t", bx_iodebug_s.monitored_mem_areas_start[area], diff --git a/bochs/iodev/iodebug.h b/bochs/iodev/iodebug.h index b0ac36f63..e6994b5e8 100644 --- a/bochs/iodev/iodebug.h +++ b/bochs/iodev/iodebug.h @@ -1,24 +1,45 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: iodebug.h,v 1.12 2008-06-04 16:28:16 sshwarts Exp $ +// $Id: iodebug.h,v 1.13 2008-12-30 18:11:13 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // +// Copyright (C) 2008 MandrakeSoft S.A. +// +// MandrakeSoft S.A. +// 43, rue d'Aboukir +// 75002 Paris - France +// http://www.linux-mandrake.com/ +// http://www.mandrakesoft.com/ +// +// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +///////////////////////////////////////////////////////////////////////// + #ifndef _BX_IODEBUG_H #define _BX_IODEBUG_H -#include "config.h" - #if BX_SUPPORT_IODEBUG #define BX_IODEBUG_MAX_AREAS 30 -class bx_iodebug_c : public bx_devmodel_c { +class bx_iodebug_c : public bx_iodebug_stub_c { public: bx_iodebug_c(); virtual ~bx_iodebug_c() {} virtual void init(void); virtual void reset (unsigned type) {} - static void mem_write(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data); - static void mem_read(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data); + virtual void mem_write(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data); + virtual void mem_read(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data); private: static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len); @@ -29,8 +50,6 @@ private: static void add_range(bx_phy_address addr_start, bx_phy_address addr_end); }; -extern bx_iodebug_c bx_iodebug; - #endif #endif diff --git a/bochs/iodev/iodev.h b/bochs/iodev/iodev.h index 42d0f3d44..a3be41507 100644 --- a/bochs/iodev/iodev.h +++ b/bochs/iodev/iodev.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: iodev.h,v 1.99 2008-12-30 15:33:37 vruppert Exp $ +// $Id: iodev.h,v 1.100 2008-12-30 18:11:13 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -51,9 +51,6 @@ class bx_pit_c; #if BX_SUPPORT_APIC class bx_ioapic_c; #endif -#if BX_SUPPORT_IODEBUG -class bx_iodebug_c; -#endif #if 0 class bx_g2h_c; #endif @@ -370,6 +367,18 @@ public: }; #endif +#if BX_SUPPORT_IODEBUG +class BOCHSAPI bx_iodebug_stub_c : public bx_devmodel_c { +public: + virtual void mem_write(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data) { + STUBFUNC(iodebug, mem_write); + } + virtual void mem_read(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data) { + STUBFUNC(iodebug, mem_read); + } +}; +#endif + class BOCHSAPI bx_devices_c : public logfunctions { public: bx_devices_c(); @@ -446,7 +455,7 @@ public: bx_busm_stub_c *pluginBusMouse; #endif #if BX_SUPPORT_IODEBUG - bx_iodebug_c *iodebug; + bx_iodebug_stub_c *pluginIODebug; #endif #if 0 bx_g2h_c *g2h; @@ -476,6 +485,9 @@ public: #if BX_SUPPORT_ACPI bx_acpi_ctrl_stub_c stubACPIController; #endif +#if BX_SUPPORT_IODEBUG + bx_iodebug_stub_c stubIODebug; +#endif // Some info to pass to devices which can handled bulk IO. This allows // the interface to remain the same for IO devices which can't handle @@ -597,9 +609,6 @@ BX_CPP_INLINE void DEV_MEM_WRITE_PHYSICAL_BLOCK(bx_phy_address phy_addr, unsigne #if BX_SUPPORT_APIC # include "iodev/ioapic.h" #endif -#if BX_SUPPORT_IODEBUG -# include "iodev/iodebug.h" -#endif #include "iodev/keyboard.h" #include "iodev/serial.h" diff --git a/bochs/memory/memory.cc b/bochs/memory/memory.cc index f8ba168a3..bcb18c56b 100644 --- a/bochs/memory/memory.cc +++ b/bochs/memory/memory.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: memory.cc,v 1.71 2008-10-18 18:10:14 sshwarts Exp $ +// $Id: memory.cc,v 1.72 2008-12-30 18:11:13 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -61,7 +61,7 @@ void BX_MEM_C::writePhysicalPage(BX_CPU_C *cpu, bx_phy_address addr, unsigned le if (cpu != NULL) { #if BX_SUPPORT_IODEBUG - bx_iodebug_c::mem_write(cpu, a20addr, len, data); + bx_devices.pluginIODebug->mem_write(cpu, a20addr, len, data); #endif BX_INSTR_PHY_WRITE(cpu->which_cpu(), a20addr, len); @@ -210,7 +210,7 @@ void BX_MEM_C::readPhysicalPage(BX_CPU_C *cpu, bx_phy_address addr, unsigned len if (cpu != NULL) { #if BX_SUPPORT_IODEBUG - bx_iodebug_c::mem_read(cpu, a20addr, len, data); + bx_devices.pluginIODebug->mem_read(cpu, a20addr, len, data); #endif BX_INSTR_PHY_READ(cpu->which_cpu(), a20addr, len); diff --git a/bochs/plugin.h b/bochs/plugin.h index 28c884c55..2ba562dca 100644 --- a/bochs/plugin.h +++ b/bochs/plugin.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: plugin.h,v 1.63 2008-11-18 20:55:59 sshwarts Exp $ +// $Id: plugin.h,v 1.64 2008-12-30 18:11:12 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // This file provides macros and types needed for plugins. It is based on @@ -46,6 +46,7 @@ extern "C" { #define BX_PLUGIN_GAMEPORT "gameport" #define BX_PLUGIN_SPEAKER "speaker" #define BX_PLUGIN_ACPI "acpi" +#define BX_PLUGIN_IODEBUG "iodebug" #define BX_REGISTER_DEVICE_DEVMODEL(a,b,c,d) pluginRegisterDeviceDevmodel(a,b,c,d) @@ -379,6 +380,7 @@ DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(extfpuirq) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(gameport) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(speaker) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(acpi) +DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(iodebug) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(amigaos) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(beos) DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(carbon)