Some Bochs plugins support and VGA extension option changes.

- Changing VGA extension to "voodoo" did not work in the config interface.
  Moved plugin loading to the string parameter handler and added plugin
  unloading case.
- Unloading "voodoo" VGA plugin resets pluginVgaDevice to stubVga.
- pluginUnregisterDeviceDevmodel() now supports core plugins.
- Some other small plugin related changes.
This commit is contained in:
Volker Ruppert 2021-01-27 20:06:02 +00:00
parent d46c80562e
commit 880ee1832a
12 changed files with 93 additions and 68 deletions

View File

@ -125,6 +125,17 @@ const char *bx_param_string_handler(bx_param_string_c *param, int set,
val = oldval;
}
}
} else if (!strcmp(pname, BXPN_VGA_EXTENSION)) {
if (set == 1) {
if ((strlen(oldval) > 0) && (strcmp(oldval, "none") && strcmp(oldval, "vbe") &&
strcmp(oldval, "cirrus"))) {
PLUG_unload_opt_plugin(oldval);
}
if ((strlen(val) > 0) && (strcmp(val, "none") && strcmp(val, "vbe") &&
strcmp(val, "cirrus"))) {
PLUG_load_vga_plugin(val);
}
}
} else {
BX_PANIC(("bx_param_string_handler called with unknown parameter '%s'", pname));
}
@ -284,7 +295,7 @@ void bx_plugin_ctrl_reset(bx_bool init_done)
SIM->opt_plugin_ctrl("*", 1);
}
bool bx_plugin_ctrl_test(const char *plugname)
bool bx_opt_plugin_available(const char *plugname)
{
return (((bx_list_c*)SIM->get_param(BXPN_PLUGIN_CTRL))->get_by_name(plugname) != NULL);
}
@ -1011,6 +1022,7 @@ void bx_init_options()
"VGA Extension",
"Name of the VGA extension",
"none", BX_PATHNAME_LEN);
vga_extension->set_handler(bx_param_string_handler);
vga_extension->set_initial_val("vbe");
display->set_options(display->SHOW_PARENT);
@ -2770,12 +2782,7 @@ static int parse_line_formatted(const char *context, int num_params, char *param
}
for (i=1; i<num_params; i++) {
if (!strncmp(params[i], "extension=", 10)) {
const char *vgaext = &params[i][10];
SIM->get_param_string(BXPN_VGA_EXTENSION)->set(vgaext);
if ((strlen(vgaext) > 0) &&
(strcmp(vgaext, "none") && strcmp(vgaext, "vbe") && strcmp(vgaext, "cirrus"))) {
PLUG_load_vga_plugin(vgaext);
}
SIM->get_param_string(BXPN_VGA_EXTENSION)->set(&params[i][10]);
} else if (!strncmp(params[i], "update_freq=", 12)) {
SIM->get_param_num(BXPN_VGA_UPDATE_FREQUENCY)->set(atol(&params[i][12]));
} else if (!strncmp(params[i], "realtime=", 9)) {
@ -3053,7 +3060,7 @@ static int parse_line_formatted(const char *context, int num_params, char *param
return SIM->parse_addon_option(context, num_params, &params[0]);
} else if (is_deprecated_option(params[0], &newparam)) {
PARSE_ERR(("%s: '%s' is deprecated - use '%s' option instead.", context, params[0], newparam));
} else if (bx_plugin_ctrl_test(params[0])) {
} else if (bx_opt_plugin_available(params[0])) {
// treat unknown option as plugin name and try to load it
if (SIM->opt_plugin_ctrl(params[0], 1)) {
if (SIM->is_addon_option(params[0])) {

View File

@ -158,9 +158,12 @@ PLUGIN_ENTRY_FOR_MODULE(voodoo)
menu->remove("voodoo");
if (theVoodooVga != NULL) {
delete theVoodooVga;
theVoodooVga = NULL;
bx_devices.pluginVgaDevice = &bx_devices.stubVga;
}
if (theVoodooDevice != NULL) {
delete theVoodooDevice;
theVoodooDevice = NULL;
}
}
return 0; // Success

View File

@ -115,7 +115,7 @@ Bit32s pcidev_options_save(FILE *fp)
// device plugin entry point
PLUGIN_ENTRY_FOR_SOUND_MODULE(pcidev)
PLUGIN_ENTRY_FOR_MODULE(pcidev)
{
if (init) {
thePciDevAdapter = new bx_pcidev_c();

View File

@ -37,7 +37,7 @@
// sound driver plugin entry point
PLUGIN_ENTRY_FOR_SOUND_MODULE(alsa)
PLUGIN_ENTRY_FOR_SND_MODULE(alsa)
{
// Nothing here yet
return 0; // Success

View File

@ -31,7 +31,7 @@
#include "soundlow.h"
PLUGIN_ENTRY_FOR_SOUND_MODULE(dummy)
PLUGIN_ENTRY_FOR_SND_MODULE(dummy)
{
// Nothing here yet
return 0; // Success

View File

@ -42,7 +42,7 @@
// sound driver plugin entry point
PLUGIN_ENTRY_FOR_SOUND_MODULE(file)
PLUGIN_ENTRY_FOR_SND_MODULE(file)
{
// Nothing here yet
return 0; // Success

View File

@ -42,7 +42,7 @@
// sound driver plugin entry point
PLUGIN_ENTRY_FOR_SOUND_MODULE(oss)
PLUGIN_ENTRY_FOR_SND_MODULE(oss)
{
// Nothing here yet
return 0; // Success

View File

@ -84,7 +84,7 @@ AudioConverterRef WaveConverter = NULL;
// sound driver plugin entry point
PLUGIN_ENTRY_FOR_SOUND_MODULE(osx)
PLUGIN_ENTRY_FOR_SND_MODULE(osx)
{
// Nothing here yet
return 0; // Success

View File

@ -38,7 +38,7 @@
// sound driver plugin entry point
PLUGIN_ENTRY_FOR_SOUND_MODULE(sdl)
PLUGIN_ENTRY_FOR_SND_MODULE(sdl)
{
// Nothing here yet
return 0; // Success

View File

@ -53,7 +53,7 @@ Bit8u *DataPointer; // returned by GlobalLock()
// sound driver plugin entry point
PLUGIN_ENTRY_FOR_SOUND_MODULE(win)
PLUGIN_ENTRY_FOR_SND_MODULE(win)
{
// Nothing here yet
return 0; // Success

View File

@ -43,11 +43,12 @@
#define PLUGIN_ENTRY_FMT_STRING "lib%s_LTX_plugin_entry"
#define GUI_PLUGIN_ENTRY_FMT_STRING "lib%s_gui_plugin_entry"
#define SOUND_PLUGIN_ENTRY_FMT_STRING "lib%s_sound_plugin_entry"
#define NET_PLUGIN_ENTRY_FMT_STRING "lib%s_net_plugin_entry"
#define USB_PLUGIN_ENTRY_FMT_STRING "lib%s_dev_plugin_entry"
#define IMG_PLUGIN_ENTRY_FMT_STRING "lib%s_img_plugin_entry"
#define PLUGIN_PATH ""
#define NET_PLUGIN_ENTRY_FMT_STRING "lib%s_net_plugin_entry"
#define SND_PLUGIN_ENTRY_FMT_STRING "lib%s_snd_plugin_entry"
#define USB_PLUGIN_ENTRY_FMT_STRING "lib%s_usb_plugin_entry"
#define PLUGIN_PATH ""
#ifndef WIN32
#define PLUGIN_FILENAME_FORMAT "libbx_%s.so"
@ -542,14 +543,14 @@ bool plugin_load(const char *name, plugintype_t type)
if (type == PLUGTYPE_GUI) {
sprintf(tmpname, GUI_PLUGIN_ENTRY_FMT_STRING, name);
} else if (type == PLUGTYPE_SND) {
sprintf(tmpname, SOUND_PLUGIN_ENTRY_FMT_STRING, name);
} else if (type == PLUGTYPE_NET) {
sprintf(tmpname, NET_PLUGIN_ENTRY_FMT_STRING, name);
} else if (type == PLUGTYPE_USB) {
sprintf(tmpname, USB_PLUGIN_ENTRY_FMT_STRING, name);
} else if (type == PLUGTYPE_IMG) {
sprintf(tmpname, IMG_PLUGIN_ENTRY_FMT_STRING, name);
} else if (type == PLUGTYPE_NET) {
sprintf(tmpname, NET_PLUGIN_ENTRY_FMT_STRING, name);
} else if (type == PLUGTYPE_SND) {
sprintf(tmpname, SND_PLUGIN_ENTRY_FMT_STRING, name);
} else if (type == PLUGTYPE_USB) {
sprintf(tmpname, USB_PLUGIN_ENTRY_FMT_STRING, name);
} else {
sprintf(tmpname, PLUGIN_ENTRY_FMT_STRING, name);
}
@ -557,7 +558,7 @@ bool plugin_load(const char *name, plugintype_t type)
plugin->plugin_entry = (plugin_entry_t) GetProcAddress(plugin->handle, tmpname);
if (plugin->plugin_entry == NULL) {
pluginlog->panic("could not find plugin_entry for module '%s' (%s): error=%d",
name, plugin_filename, GetLastError());
name, plugin_filename, GetLastError());
plugin_abort(plugin);
return 0;
}
@ -565,7 +566,7 @@ bool plugin_load(const char *name, plugintype_t type)
plugin->plugin_entry = (plugin_entry_t) lt_dlsym(plugin->handle, tmpname);
if (plugin->plugin_entry == NULL) {
pluginlog->panic("could not find plugin_entry for module '%s' (%s): %s",
name, plugin_filename, lt_dlerror());
name, plugin_filename, lt_dlerror());
plugin_abort(plugin);
return 0;
}
@ -698,14 +699,27 @@ void pluginRegisterDeviceDevmodel(plugin_t *plugin, plugintype_t type, bx_devmod
/* Plugin system: Remove registered plugin device */
/************************************************************************/
void pluginUnregisterDeviceDevmodel(const char *name)
void pluginUnregisterDeviceDevmodel(const char *name, plugintype_t type)
{
device_t **devlist;
device_t *device, *prev = NULL;
for (device = devices; device; device = device->next) {
switch (type) {
case PLUGTYPE_CORE:
case PLUGTYPE_VGA:
devlist = &core_devices;
break;
case PLUGTYPE_STANDARD:
case PLUGTYPE_OPTIONAL:
default:
devlist = &devices;
break;
}
for (device = *devlist; device; device = device->next) {
if (!strcmp(name, device->name)) {
if (prev == NULL) {
devices = device->next;
*devlist = device->next;
} else {
prev->next = device->next;
}
@ -762,7 +776,7 @@ bool bx_unload_plugin(const char *name, bx_bool devflag)
for (plugin = plugins; plugin; plugin = plugin->next) {
if (!strcmp(plugin->name, name)) {
if (devflag) {
pluginUnregisterDeviceDevmodel(plugin->name);
pluginUnregisterDeviceDevmodel(plugin->name, plugin->type);
}
ret = plugin_unload(plugin);
break;
@ -928,16 +942,15 @@ void bx_plugins_after_restore_state()
#if !BX_PLUGINS
// Special code for loading gui, optional and sound plugins when plugin support
// is turned off.
// Special code for handling modules when plugin support is turned off.
#define BUILTIN_GUI_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_GUI, lib##mod##_gui_plugin_entry, 0}
#define BUILTIN_OPT_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_OPTIONAL, lib##mod##_LTX_plugin_entry, 0}
#define BUILTIN_SND_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_SND, lib##mod##_sound_plugin_entry, 0}
#define BUILTIN_NET_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_NET, lib##mod##_net_plugin_entry, 0}
#define BUILTIN_USB_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_USB, lib##mod##_dev_plugin_entry, 0}
#define BUILTIN_VGA_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_VGA, lib##mod##_LTX_plugin_entry, 0}
#define BUILTIN_GUI_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_GUI, lib##mod##_gui_plugin_entry, 0}
#define BUILTIN_IMG_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_IMG, lib##mod##_img_plugin_entry, 0}
#define BUILTIN_NET_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_NET, lib##mod##_net_plugin_entry, 0}
#define BUILTIN_SND_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_SND, lib##mod##_snd_plugin_entry, 0}
#define BUILTIN_USB_PLUGIN_ENTRY(mod) {#mod, PLUGTYPE_USB, lib##mod##_dev_plugin_entry, 0}
plugin_t bx_builtin_plugins[] = {
#if BX_WITH_AMIGAOS
@ -1109,12 +1122,14 @@ int bx_unload_opt_plugin(const char *name, bx_bool devflag)
int i = 0;
while (strcmp(bx_builtin_plugins[i].name, "NULL")) {
if ((!strcmp(name, bx_builtin_plugins[i].name)) &&
(bx_builtin_plugins[i].type == PLUGTYPE_OPTIONAL)) {
((bx_builtin_plugins[i].type == PLUGTYPE_OPTIONAL) ||
(bx_builtin_plugins[i].type == PLUGTYPE_VGA))) {
if (bx_builtin_plugins[i].initialized == 1) {
if (devflag) {
pluginUnregisterDeviceDevmodel(bx_builtin_plugins[i].name);
pluginUnregisterDeviceDevmodel(bx_builtin_plugins[i].name,
bx_builtin_plugins[i].type);
}
bx_builtin_plugins[i].plugin_entry(NULL, PLUGTYPE_OPTIONAL, 0);
bx_builtin_plugins[i].plugin_entry(NULL, bx_builtin_plugins[i].type, 0);
bx_builtin_plugins[i].initialized = 0;
}
return 1;

View File

@ -77,7 +77,7 @@ extern "C" {
#define BX_REGISTER_DEVICE_DEVMODEL(a,b,c,d) pluginRegisterDeviceDevmodel(a,b,c,d)
#define BX_UNREGISTER_DEVICE_DEVMODEL(a) pluginUnregisterDeviceDevmodel(a)
#define BX_UNREGISTER_DEVICE_DEVMODEL(a,b) pluginUnregisterDeviceDevmodel(a,b)
#define PLUG_device_present(a) pluginDevicePresent(a)
#if BX_PLUGINS
@ -297,7 +297,7 @@ typedef void (*deviceInitDev_t)(void);
typedef void (*deviceReset_t)(unsigned);
BOCHSAPI void pluginRegisterDeviceDevmodel(plugin_t *plugin, plugintype_t type, bx_devmodel_c *dev, const char *name);
BOCHSAPI void pluginUnregisterDeviceDevmodel(const char *name);
BOCHSAPI void pluginUnregisterDeviceDevmodel(const char *name, plugintype_t type);
BOCHSAPI bx_bool pluginDevicePresent(const char *name);
/* === IO port stuff === */
@ -364,14 +364,14 @@ int plugin_entry(plugin_t *plugin, plugintype_t type, bool init);
extern "C" __declspec(dllexport) int __cdecl lib##mod##_LTX_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_GUI_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_gui_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_SOUND_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_sound_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_NET_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_net_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_USB_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_dev_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_IMG_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_img_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_NET_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_net_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_SND_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_snd_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_USB_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_usb_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#elif BX_PLUGINS
@ -379,14 +379,14 @@ int plugin_entry(plugin_t *plugin, plugintype_t type, bool init);
extern "C" int CDECL lib##mod##_LTX_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_GUI_MODULE(mod) \
extern "C" int CDECL lib##mod##_gui_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_SOUND_MODULE(mod) \
extern "C" int CDECL lib##mod##_sound_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_NET_MODULE(mod) \
extern "C" int CDECL lib##mod##_net_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_USB_MODULE(mod) \
extern "C" int CDECL lib##mod##_dev_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_IMG_MODULE(mod) \
extern "C" int CDECL lib##mod##_img_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_NET_MODULE(mod) \
extern "C" int CDECL lib##mod##_net_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_SND_MODULE(mod) \
extern "C" int CDECL lib##mod##_snd_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_USB_MODULE(mod) \
extern "C" int CDECL lib##mod##_usb_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#else
@ -394,14 +394,14 @@ int plugin_entry(plugin_t *plugin, plugintype_t type, bool init);
int CDECL lib##mod##_LTX_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_GUI_MODULE(mod) \
int CDECL lib##mod##_gui_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_SOUND_MODULE(mod) \
int CDECL lib##mod##_sound_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_NET_MODULE(mod) \
int CDECL lib##mod##_net_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_USB_MODULE(mod) \
int CDECL lib##mod##_dev_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_IMG_MODULE(mod) \
int CDECL lib##mod##_img_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_NET_MODULE(mod) \
int CDECL lib##mod##_net_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_SND_MODULE(mod) \
int CDECL lib##mod##_snd_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
#define PLUGIN_ENTRY_FOR_USB_MODULE(mod) \
int CDECL lib##mod##_dev_plugin_entry(plugin_t *plugin, plugintype_t type, bool init)
// device plugins
PLUGIN_ENTRY_FOR_MODULE(harddrv);
@ -454,13 +454,13 @@ PLUGIN_ENTRY_FOR_GUI_MODULE(win32);
PLUGIN_ENTRY_FOR_GUI_MODULE(wx);
PLUGIN_ENTRY_FOR_GUI_MODULE(x);
// sound driver plugins
PLUGIN_ENTRY_FOR_SOUND_MODULE(alsa);
PLUGIN_ENTRY_FOR_SOUND_MODULE(dummy);
PLUGIN_ENTRY_FOR_SOUND_MODULE(file);
PLUGIN_ENTRY_FOR_SOUND_MODULE(oss);
PLUGIN_ENTRY_FOR_SOUND_MODULE(osx);
PLUGIN_ENTRY_FOR_SOUND_MODULE(sdl);
PLUGIN_ENTRY_FOR_SOUND_MODULE(win);
PLUGIN_ENTRY_FOR_SND_MODULE(alsa);
PLUGIN_ENTRY_FOR_SND_MODULE(dummy);
PLUGIN_ENTRY_FOR_SND_MODULE(file);
PLUGIN_ENTRY_FOR_SND_MODULE(oss);
PLUGIN_ENTRY_FOR_SND_MODULE(osx);
PLUGIN_ENTRY_FOR_SND_MODULE(sdl);
PLUGIN_ENTRY_FOR_SND_MODULE(win);
// network driver plugins
PLUGIN_ENTRY_FOR_NET_MODULE(fbsd);
PLUGIN_ENTRY_FOR_NET_MODULE(linux);