- added special linked list for core plugins and manage them with the device

plugin system.The load order is important for these devices!
- load support plugins for networking, sound and usb only if at least one of the
  related plugin devices is loaded.
- plugin_ctrl: added missing devices to the list in bochsrc sample
This commit is contained in:
Volker Ruppert 2012-01-13 17:04:47 +00:00
parent fb9401c3b0
commit e4570a0939
4 changed files with 73 additions and 85 deletions

View File

@ -8,8 +8,8 @@
# only available when the plugin device is loaded. The value "1" means to load
# the plugin and "0" will unload it (if loaded before).
# These plugins are currently supported: 'biosdev', 'e1000', 'es1370',
# 'extfpuirq', 'gameport', 'iodebug', 'pcidev', 'pcipnic', 'speaker',
# 'unmapped', 'usb_ohci', 'usb_uhci' and 'usb_xhci'.
# 'extfpuirq', 'gameport', 'iodebug', 'ne2k', 'pcidev', 'pcipnic', 'sb16',
# 'speaker', 'unmapped', 'usb_ohci', 'usb_uhci' and 'usb_xhci'.
#=======================================================================
#plugin_ctrl: unmapped=1, biosdev=1, speaker=1, e1000=1

View File

@ -161,33 +161,35 @@ void bx_devices_c::init(BX_MEM_C *newmem)
// "by hand" in this file. Basically, we're using core plugins when we
// want to control the init order.
//
PLUG_load_plugin(cmos, PLUGTYPE_CORE);
PLUG_load_plugin(dma, PLUGTYPE_CORE);
PLUG_load_plugin(pic, PLUGTYPE_CORE);
PLUG_load_plugin(pit, PLUGTYPE_CORE);
PLUG_load_plugin(vga, PLUGTYPE_CORE);
PLUG_load_plugin(hdimage, PLUGTYPE_CORE);
PLUG_load_plugin(floppy, PLUGTYPE_CORE);
#if BX_SUPPORT_SOUNDLOW
PLUG_load_plugin(soundmod, PLUGTYPE_CORE);
#endif
#if BX_NETWORKING
PLUG_load_plugin(netmod, PLUGTYPE_CORE);
if (is_network_enabled())
PLUG_load_plugin(netmod, PLUGTYPE_CORE);
#endif
#if BX_SUPPORT_SOUNDLOW
if (is_sound_enabled())
PLUG_load_plugin(soundmod, PLUGTYPE_CORE);
#endif
// PCI logic (i440FX)
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
#if BX_SUPPORT_PCI
PLUG_load_plugin(pci, PLUGTYPE_CORE);
PLUG_load_plugin(pci2isa, PLUGTYPE_CORE);
#if BX_SUPPORT_PCIUSB
PLUG_load_plugin(usb_common, PLUGTYPE_CORE);
if (is_usb_enabled())
PLUG_load_plugin(usb_common, PLUGTYPE_CORE);
#endif
PLUG_load_plugin(acpi, PLUGTYPE_STANDARD);
#else
BX_ERROR(("Bochs is not compiled with PCI support"));
#endif
}
PLUG_load_plugin(cmos, PLUGTYPE_CORE);
PLUG_load_plugin(dma, PLUGTYPE_CORE);
PLUG_load_plugin(pic, PLUGTYPE_CORE);
PLUG_load_plugin(pit, PLUGTYPE_CORE);
PLUG_load_plugin(floppy, PLUGTYPE_CORE);
PLUG_load_plugin(vga, PLUGTYPE_CORE);
#if BX_SUPPORT_APIC
PLUG_load_plugin(ioapic, PLUGTYPE_STANDARD);
@ -221,29 +223,6 @@ void bx_devices_c::init(BX_MEM_C *newmem)
}
#endif
// CMOS RAM & RTC
pluginCmosDevice->init();
/*--- 8237 DMA ---*/
pluginDmaDevice->init();
//--- FLOPPY ---
pluginFloppyDevice->init();
#if BX_SUPPORT_PCI
pluginPciBridge->init();
pluginPci2IsaBridge->init();
#endif
/*--- VGA adapter ---*/
pluginVgaDevice->init();
/*--- 8259A PIC ---*/
pluginPicDevice->init();
/*--- 82C54 PIT ---*/
pluginPitDevice->init();
// system hardware
register_io_read_handler(this, &read_handler, 0x0092,
"Port 92h System Control", 1);
@ -296,38 +275,12 @@ void bx_devices_c::init(BX_MEM_C *newmem)
void bx_devices_c::reset(unsigned type)
{
mem->disable_smram();
#if BX_SUPPORT_PCI
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
pluginPciBridge->reset(type);
pluginPci2IsaBridge->reset(type);
}
#endif
pluginCmosDevice->reset(type);
pluginDmaDevice->reset(type);
pluginFloppyDevice->reset(type);
pluginVgaDevice->reset(type);
pluginPicDevice->reset(type);
pluginPitDevice->reset(type);
// now reset optional plugins
bx_reset_plugins(type);
}
void bx_devices_c::register_state()
{
bx_virt_timer.register_state();
#if BX_SUPPORT_PCI
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
pluginPciBridge->register_state();
pluginPci2IsaBridge->register_state();
}
#endif
pluginCmosDevice->register_state();
pluginDmaDevice->register_state();
pluginFloppyDevice->register_state();
pluginVgaDevice->register_state();
pluginPicDevice->register_state();
pluginPitDevice->register_state();
// now register state of optional plugins
bx_plugins_register_state();
}
@ -335,14 +288,6 @@ void bx_devices_c::after_restore_state()
{
bx_slowdown_timer.after_restore_state();
bx_virt_timer.set_realtime_delay();
#if BX_SUPPORT_PCI
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
pluginPciBridge->after_restore_state();
pluginPci2IsaBridge->after_restore_state();
}
#endif
pluginCmosDevice->after_restore_state();
pluginVgaDevice->after_restore_state();
bx_plugins_after_restore_state();
}
@ -984,6 +929,35 @@ bx_bool bx_devices_c::is_parallel_enabled(void)
return 0;
}
bx_bool bx_devices_c::is_network_enabled(void)
{
if (PLUG_device_present("e1000") ||
PLUG_device_present("ne2k") ||
PLUG_device_present("pcipnic")) {
return 1;
}
return 0;
}
bx_bool bx_devices_c::is_sound_enabled(void)
{
if (PLUG_device_present("es1370") ||
PLUG_device_present("sb16")) {
return 1;
}
return 0;
}
bx_bool bx_devices_c::is_usb_enabled(void)
{
if (PLUG_device_present("usb_ohci") ||
PLUG_device_present("usb_uhci") ||
PLUG_device_present("usb_xhci")) {
return 1;
}
return 0;
}
// removable keyboard/mouse registration
void bx_devices_c::register_removable_keyboard(void *dev, bx_keyb_enq_t keyb_enq)
{

View File

@ -592,6 +592,9 @@ private:
bx_bool is_harddrv_enabled();
bx_bool is_serial_enabled();
bx_bool is_parallel_enabled();
bx_bool is_network_enabled();
bx_bool is_sound_enabled();
bx_bool is_usb_enabled();
};
// memory stub has an assumption that there are no memory accesses splitting 4K page

View File

@ -88,6 +88,7 @@ static void plugin_init_one(plugin_t *plugin);
#endif
device_t *devices = NULL; /* Head of the linked list of registered devices */
device_t *core_devices = NULL; /* Head of the linked list of registered core devices */
plugin_t *current_plugin_context = NULL;
@ -545,7 +546,7 @@ plugin_startup(void)
void pluginRegisterDeviceDevmodel(plugin_t *plugin, plugintype_t type, bx_devmodel_c *devmodel, const char *name)
{
device_t *device;
device_t *device, **devlist;
device = (device_t *)malloc (sizeof (device_t));
if (!device)
@ -558,31 +559,26 @@ void pluginRegisterDeviceDevmodel(plugin_t *plugin, plugintype_t type, bx_devmod
device->devmodel = devmodel;
device->plugin = plugin; // this can be NULL
device->next = NULL;
device->plugtype = type;
// Don't add every kind of device to the list.
switch (type) {
case PLUGTYPE_CORE:
// Core devices are present whether or not we are using plugins, so
// they are managed by the same code in iodev/devices.cc whether
// plugins are on or off.
free(device);
return; // Do not add core devices to the devices list.
devlist = &core_devices;
break;
case PLUGTYPE_STANDARD:
case PLUGTYPE_OPTIONAL:
case PLUGTYPE_USER:
default:
// The plugin system will manage standard, optional and user devices only.
device->plugtype = type;
devlist = &devices;
break;
}
if (!devices) {
if (!*devlist) {
/* Empty list, this become the first entry. */
devices = device;
}
else {
*devlist = device;
} else {
/* Non-empty list. Add to end. */
device_t *temp = devices;
device_t *temp = *devlist;
while (temp->next)
temp = temp->next;
@ -675,6 +671,10 @@ void bx_init_plugins()
{
device_t *device;
for (device = core_devices; device; device = device->next) {
pluginlog->info("init_dev of '%s' plugin device by virtual method",device->name);
device->devmodel->init();
}
for (device = devices; device; device = device->next) {
if (device->plugtype == PLUGTYPE_STANDARD) {
pluginlog->info("init_dev of '%s' plugin device by virtual method",device->name);
@ -705,6 +705,10 @@ void bx_reset_plugins(unsigned signal)
{
device_t *device;
for (device = core_devices; device; device = device->next) {
pluginlog->info("reset of '%s' plugin device by virtual method",device->name);
device->devmodel->reset(signal);
}
for (device = devices; device; device = device->next) {
if (device->plugtype == PLUGTYPE_STANDARD) {
pluginlog->info("reset of '%s' plugin device by virtual method",device->name);
@ -763,6 +767,10 @@ void bx_plugins_register_state()
{
device_t *device;
for (device = core_devices; device; device = device->next) {
pluginlog->info("register state of '%s' plugin device by virtual method",device->name);
device->devmodel->register_state();
}
for (device = devices; device; device = device->next) {
pluginlog->info("register state of '%s' plugin device by virtual method",device->name);
device->devmodel->register_state();
@ -777,6 +785,9 @@ void bx_plugins_after_restore_state()
{
device_t *device;
for (device = core_devices; device; device = device->next) {
device->devmodel->after_restore_state();
}
for (device = devices; device; device = device->next) {
if (device->plugtype == PLUGTYPE_STANDARD) {
device->devmodel->after_restore_state();