- added function for loading optional plugins in case the plugin support is
turned off. Removed workaround code from devices.cc. - removed 'pci_ide' plugin from the optional plugin control, since it depends on the presence of 'pci' and 'harddrv'. - define types for plugin init/fini functions
This commit is contained in:
parent
d070de30dd
commit
38a797f502
@ -1778,7 +1778,7 @@ void bx_init_options()
|
||||
enabled->set_dependent_list(menu->clone());
|
||||
|
||||
// optional plugin control
|
||||
menu = new bx_list_c(misc, "plugin_ctrl", "Optional Plugin Control", 9);
|
||||
menu = new bx_list_c(misc, "plugin_ctrl", "Optional Plugin Control", 8);
|
||||
menu->set_options(menu->SHOW_PARENT | menu->USE_BOX_TITLE);
|
||||
new bx_param_bool_c(menu, "unmapped", "Enable 'unmapped'", "", 1);
|
||||
new bx_param_bool_c(menu, "biosdev", "Enable 'biosdev'", "", 1);
|
||||
@ -1791,7 +1791,6 @@ void bx_init_options()
|
||||
new bx_param_bool_c(menu, "iodebug", "Enable 'iodebug'", "", 1);
|
||||
#endif
|
||||
#if BX_SUPPORT_PCI
|
||||
new bx_param_bool_c(menu, "pci_ide", "Enable 'pci_ide'", "", 1);
|
||||
new bx_param_bool_c(menu, "acpi", "Enable 'acpi'", "", 1);
|
||||
#endif
|
||||
#if BX_SUPPORT_APIC
|
||||
|
@ -34,6 +34,9 @@ enum plugintype_t {
|
||||
|
||||
#define MAX_ARGC 10
|
||||
|
||||
typedef int (*plugin_init_t)(struct _plugin_t *plugin, plugintype_t type, int argc, char *argv[]);
|
||||
typedef void (*plugin_fini_t)(void);
|
||||
|
||||
typedef struct _plugin_t
|
||||
{
|
||||
plugintype_t type;
|
||||
@ -47,8 +50,8 @@ typedef struct _plugin_t
|
||||
#endif
|
||||
int argc;
|
||||
char *name, *args, *argv[MAX_ARGC];
|
||||
int (*plugin_init)(struct _plugin_t *plugin, plugintype_t type, int argc, char *argv[]);
|
||||
void (*plugin_fini)(void);
|
||||
plugin_init_t plugin_init;
|
||||
plugin_fini_t plugin_fini;
|
||||
|
||||
struct _plugin_t *next;
|
||||
} plugin_t;
|
||||
|
@ -108,9 +108,6 @@ void bx_devices_c::init(BX_MEM_C *newmem)
|
||||
const char *vga_ext;
|
||||
bx_list_c *plugin_ctrl;
|
||||
bx_param_bool_c *plugin;
|
||||
#if !BX_PLUGINS
|
||||
const char *plugname;
|
||||
#endif
|
||||
|
||||
BX_DEBUG(("Init $Id$"));
|
||||
mem = newmem;
|
||||
@ -190,7 +187,6 @@ void bx_devices_c::init(BX_MEM_C *newmem)
|
||||
#endif
|
||||
} else {
|
||||
plugin_ctrl = (bx_list_c*)SIM->get_param(BXPN_PLUGIN_CTRL);
|
||||
SIM->get_param_bool(BX_PLUGIN_PCI_IDE, plugin_ctrl)->set(0);
|
||||
SIM->get_param_bool(BX_PLUGIN_ACPI, plugin_ctrl)->set(0);
|
||||
}
|
||||
#else
|
||||
@ -203,47 +199,7 @@ void bx_devices_c::init(BX_MEM_C *newmem)
|
||||
for (i = 0; i < (unsigned)plugin_ctrl->get_size(); i++) {
|
||||
plugin = (bx_param_bool_c*)(plugin_ctrl->get(i));
|
||||
if (plugin->get()) {
|
||||
#if BX_PLUGINS
|
||||
PLUG_load_opt_plugin(plugin->get_name());
|
||||
#else
|
||||
// workaround in case of plugins disabled
|
||||
plugname = plugin->get_name();
|
||||
if (!strcmp(plugname, BX_PLUGIN_UNMAPPED)) {
|
||||
PLUG_load_plugin(unmapped, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
else if (!strcmp(plugname, BX_PLUGIN_BIOSDEV)) {
|
||||
PLUG_load_plugin(biosdev, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
else if (!strcmp(plugname, BX_PLUGIN_SPEAKER)) {
|
||||
PLUG_load_plugin(speaker, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
else if (!strcmp(plugname, BX_PLUGIN_EXTFPUIRQ)) {
|
||||
PLUG_load_plugin(extfpuirq, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
#if BX_SUPPORT_GAMEPORT
|
||||
else if (!strcmp(plugname, BX_PLUGIN_GAMEPORT)) {
|
||||
PLUG_load_plugin(gameport, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
#endif
|
||||
#if BX_SUPPORT_IODEBUG
|
||||
else if (!strcmp(plugname, BX_PLUGIN_IODEBUG)) {
|
||||
PLUG_load_plugin(iodebug, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
#endif
|
||||
#if BX_SUPPORT_PCI
|
||||
else if (!strcmp(plugname, BX_PLUGIN_PCI_IDE)) {
|
||||
PLUG_load_plugin(pci_ide, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
else if (!strcmp(plugname, BX_PLUGIN_ACPI)) {
|
||||
PLUG_load_plugin(acpi, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
#endif
|
||||
#if BX_SUPPORT_APIC
|
||||
else if (!strcmp(plugname, BX_PLUGIN_IOAPIC)) {
|
||||
PLUG_load_plugin(ioapic, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,8 +209,14 @@ void bx_devices_c::init(BX_MEM_C *newmem)
|
||||
PLUG_load_plugin(busmouse, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
#endif
|
||||
if (is_harddrv_enabled())
|
||||
if (is_harddrv_enabled()) {
|
||||
PLUG_load_plugin(harddrv, PLUGTYPE_OPTIONAL);
|
||||
#if BX_SUPPORT_PCI
|
||||
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
|
||||
PLUG_load_plugin(pci_ide, PLUGTYPE_OPTIONAL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (is_serial_enabled())
|
||||
PLUG_load_plugin(serial, PLUGTYPE_OPTIONAL);
|
||||
if (is_parallel_enabled())
|
||||
|
@ -427,17 +427,13 @@ void plugin_load(char *name, char *args, plugintype_t type)
|
||||
sprintf(buf, PLUGIN_INIT_FMT_STRING, "user");
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
plugin->plugin_init =
|
||||
(int (*)(struct _plugin_t *, enum plugintype_t, int, char *[])) /* monster typecast */
|
||||
GetProcAddress(plugin->handle, buf);
|
||||
plugin->plugin_init = (plugin_init_t) GetProcAddress(plugin->handle, buf);
|
||||
if (plugin->plugin_init == NULL) {
|
||||
pluginlog->panic("could not find plugin_init: error=%d", GetLastError());
|
||||
plugin_abort ();
|
||||
}
|
||||
#else
|
||||
plugin->plugin_init =
|
||||
(int (*)(struct _plugin_t *, enum plugintype_t, int, char *[])) /* monster typecast */
|
||||
lt_dlsym (plugin->handle, buf);
|
||||
plugin->plugin_init = (plugin_init_t) lt_dlsym (plugin->handle, buf);
|
||||
if (plugin->plugin_init == NULL) {
|
||||
pluginlog->panic("could not find plugin_init: %s", lt_dlerror ());
|
||||
plugin_abort ();
|
||||
@ -450,13 +446,13 @@ void plugin_load(char *name, char *args, plugintype_t type)
|
||||
sprintf(buf, PLUGIN_FINI_FMT_STRING, "user");
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
plugin->plugin_fini = (void (*)(void)) GetProcAddress(plugin->handle, buf);
|
||||
plugin->plugin_fini = (plugin_fini_t) GetProcAddress(plugin->handle, buf);
|
||||
if (plugin->plugin_fini == NULL) {
|
||||
pluginlog->panic("could not find plugin_fini: error=%d", GetLastError());
|
||||
plugin_abort ();
|
||||
}
|
||||
#else
|
||||
plugin->plugin_fini = (void (*)(void)) lt_dlsym (plugin->handle, buf);
|
||||
plugin->plugin_fini = (plugin_fini_t) lt_dlsym (plugin->handle, buf);
|
||||
if (plugin->plugin_fini == NULL) {
|
||||
pluginlog->panic("could not find plugin_fini: %s", lt_dlerror ());
|
||||
plugin_abort();
|
||||
@ -806,4 +802,51 @@ void bx_plugins_after_restore_state()
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !BX_PLUGINS
|
||||
|
||||
// special code for loading optional plugins when plugins are turned off
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
plugin_init_t plugin_init;
|
||||
} builtin_plugin_t;
|
||||
|
||||
#define BUILTIN_PLUGIN_ENTRY(mod) {#mod, lib##mod##_LTX_plugin_init}
|
||||
|
||||
const builtin_plugin_t builtin_opt_plugins[] = {
|
||||
BUILTIN_PLUGIN_ENTRY(unmapped),
|
||||
BUILTIN_PLUGIN_ENTRY(biosdev),
|
||||
BUILTIN_PLUGIN_ENTRY(speaker),
|
||||
BUILTIN_PLUGIN_ENTRY(extfpuirq),
|
||||
#if BX_SUPPORT_GAMEPORT
|
||||
BUILTIN_PLUGIN_ENTRY(gameport),
|
||||
#endif
|
||||
#if BX_SUPPORT_IODEBUG
|
||||
BUILTIN_PLUGIN_ENTRY(iodebug),
|
||||
#endif
|
||||
#if BX_SUPPORT_PCI
|
||||
BUILTIN_PLUGIN_ENTRY(pci_ide),
|
||||
BUILTIN_PLUGIN_ENTRY(acpi),
|
||||
#endif
|
||||
#if BX_SUPPORT_APIC
|
||||
BUILTIN_PLUGIN_ENTRY(ioapic),
|
||||
#endif
|
||||
{"NULL", NULL}
|
||||
};
|
||||
|
||||
int bx_load_plugin(const char *name, plugintype_t type)
|
||||
{
|
||||
int i = 0;
|
||||
while (strcmp(builtin_opt_plugins[i].name, "NULL")) {
|
||||
if (!strcmp(name, builtin_opt_plugins[i].name)) {
|
||||
builtin_opt_plugins[i].plugin_init(NULL, type, 0, NULL);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -106,6 +106,7 @@ extern "C" {
|
||||
// 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);}
|
||||
#define PLUG_load_opt_plugin(name) {bx_load_plugin(name,PLUGTYPE_OPTIONAL);}
|
||||
#define PLUG_unload_plugin(name) {lib##name##_LTX_plugin_fini();}
|
||||
#define DEV_register_ioread_handler(b,c,d,e,f) bx_devices.register_io_read_handler(b,c,d,e,f)
|
||||
#define DEV_register_iowrite_handler(b,c,d,e,f) bx_devices.register_io_write_handler(b,c,d,e,f)
|
||||
|
Loading…
Reference in New Issue
Block a user