2.7. The Bochs devices base class bx_devmodel_c

All devices models located on or connected to the Bochs "mainboard" are based on the bx_devmodel_c class. It is defined in iodev.h and it has been introduced along with the plugin interface. That's why the device registration code is still located in plugin.cc, but it is present independent from the --enable-plugins switch. Some code in devices.cc uses the device registration to initialize or reset all devices. It also calls required methods of the save/restore feature. If the debugger is present, a device can resister a method to dump it's status. This is the definition of this class:

class BOCHSAPI bx_devmodel_c : public logfunctions {
  public:
  virtual ~bx_devmodel_c() {}
  virtual void init(void) {}
  virtual void reset(unsigned type) {}
  virtual void register_state(void) {}
  virtual void after_restore_state(void) {}
#if BX_DEBUGGER
  virtual void debug_dump(int argc, char **argv) {}
#endif
};

A device registers it registers itself in the module / plugin init code. In the plugins case the unregister function is called before unloading the plugin. These are the macro definitions that point to functions for registering / unregistering a device and for checking whether or not a device is registered:

#define BX_REGISTER_DEVICE_DEVMODEL(a,b,c,d) pluginRegisterDeviceDevmodel(a,b,c,d)
#define BX_UNREGISTER_DEVICE_DEVMODEL(a,b) pluginUnregisterDeviceDevmodel(a,b)
#define PLUG_device_present(a) pluginDevicePresent(a)