Rewrite of the networking module handling similar to the hdimage module
handling. Networking module names are now stored as string constants instead of hardcoded values. Available modules are detected at Bochs startup and stored in a string array before initializing options. In the plugins case available modules are read from the plugins list. If plugins are off, the eth_locator_c registry is used. Related changes in all parts of Bochs that need the networking stuff. TODO #1: Sound drivers could be handled in a similar way.
This commit is contained in:
parent
96193ed79c
commit
1fe24e32b0
@ -22,6 +22,9 @@
|
||||
#include "bxversion.h"
|
||||
#include "iodev/iodev.h"
|
||||
#include "iodev/hdimage/hdimage.h"
|
||||
#if BX_NETWORKING
|
||||
#include "iodev/network/netmod.h"
|
||||
#endif
|
||||
#include "param_names.h"
|
||||
#include <assert.h>
|
||||
|
||||
@ -144,37 +147,6 @@ const char *bx_param_string_handler(bx_param_string_c *param, int set,
|
||||
|
||||
void bx_init_std_nic_options(const char *name, bx_list_c *menu)
|
||||
{
|
||||
// networking module choices
|
||||
static const char *eth_module_list[] = {
|
||||
"null",
|
||||
#if BX_NETMOD_LINUX
|
||||
"linux",
|
||||
#endif
|
||||
#if BX_NETMOD_TAP
|
||||
"tap",
|
||||
#endif
|
||||
#if BX_NETMOD_TUNTAP
|
||||
"tuntap",
|
||||
#endif
|
||||
#if BX_NETMOD_WIN32
|
||||
"win32",
|
||||
#endif
|
||||
#if BX_NETMOD_FBSD
|
||||
"fbsd",
|
||||
#endif
|
||||
#if BX_NETMOD_VDE
|
||||
"vde",
|
||||
#endif
|
||||
#if BX_NETMOD_SLIRP
|
||||
"slirp",
|
||||
#endif
|
||||
#if BX_NETMOD_SOCKET
|
||||
"socket",
|
||||
#endif
|
||||
"vnet",
|
||||
NULL
|
||||
};
|
||||
|
||||
bx_param_enum_c *ethmod;
|
||||
bx_param_bytestring_c *macaddr;
|
||||
bx_param_filename_c *path, *bootrom;
|
||||
@ -192,7 +164,7 @@ void bx_init_std_nic_options(const char *name, bx_list_c *menu)
|
||||
"ethmod",
|
||||
"Ethernet module",
|
||||
"Module used for the connection to the real net.",
|
||||
eth_module_list,
|
||||
bx_netmod_ctl.get_module_names(),
|
||||
0,
|
||||
0);
|
||||
ethmod->set_by_name("null");
|
||||
@ -1538,10 +1510,13 @@ void bx_init_options()
|
||||
usb->set_options(usb->USE_TAB_WINDOW | usb->SHOW_PARENT);
|
||||
// USB host controller options initialized in the devive plugin code
|
||||
|
||||
#if BX_NETWORKING
|
||||
// network subtree
|
||||
bx_list_c *network = new bx_list_c(root_param, "network", "Network Configuration");
|
||||
network->set_options(network->USE_TAB_WINDOW | network->SHOW_PARENT);
|
||||
bx_netmod_ctl.init();
|
||||
// network device options initialized in the devive plugin code
|
||||
#endif
|
||||
|
||||
// sound subtree
|
||||
bx_list_c *sound = new bx_list_c(root_param, "sound", "Sound Configuration");
|
||||
|
@ -67,6 +67,9 @@ bx_devices_c::~bx_devices_c()
|
||||
{
|
||||
timer_handle = BX_NULL_TIMER_HANDLE;
|
||||
bx_hdimage_ctl.exit();
|
||||
#if BX_NETWORKING
|
||||
bx_netmod_ctl.exit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void bx_devices_c::init_stubs()
|
||||
@ -171,17 +174,6 @@ void bx_devices_c::init(BX_MEM_C *newmem)
|
||||
bx_virt_timer.init();
|
||||
bx_slowdown_timer.init();
|
||||
|
||||
// BBD: At present, the only difference between "core" and "optional"
|
||||
// plugins is that initialization and reset of optional plugins is handled
|
||||
// by the plugin device list (). Init and reset of core plugins is done
|
||||
// "by hand" in this file. Basically, we're using core plugins when we
|
||||
// want to control the init order.
|
||||
//
|
||||
#if BX_NETWORKING
|
||||
network_enabled = is_network_enabled();
|
||||
if (network_enabled)
|
||||
bx_netmod_ctl.init();
|
||||
#endif
|
||||
#if BX_SUPPORT_SOUNDLOW
|
||||
sound_enabled = is_sound_enabled();
|
||||
if (sound_enabled) {
|
||||
@ -457,10 +449,6 @@ void bx_devices_c::exit()
|
||||
// unload optional plugins first
|
||||
bx_unload_plugins();
|
||||
bx_unload_core_plugins();
|
||||
#if BX_NETWORKING
|
||||
if (network_enabled)
|
||||
bx_netmod_ctl.exit();
|
||||
#endif
|
||||
#if BX_SUPPORT_SOUNDLOW
|
||||
if (sound_enabled)
|
||||
bx_soundmod_ctl.exit();
|
||||
|
@ -34,6 +34,8 @@
|
||||
|
||||
bx_netmod_ctl_c bx_netmod_ctl;
|
||||
|
||||
const char **net_module_names;
|
||||
|
||||
bx_netmod_ctl_c::bx_netmod_ctl_c()
|
||||
{
|
||||
put("netmodctl", "NETCTL");
|
||||
@ -41,11 +43,57 @@ bx_netmod_ctl_c::bx_netmod_ctl_c()
|
||||
|
||||
void bx_netmod_ctl_c::init(void)
|
||||
{
|
||||
// Nothing here yet
|
||||
Bit8u count = 0;
|
||||
|
||||
#if !BX_PLUGINS
|
||||
count = eth_locator_c::get_modules_count();
|
||||
#else
|
||||
count = PLUG_get_plugins_count(PLUGTYPE_NET);
|
||||
#endif
|
||||
net_module_names = (const char**) malloc((count + 1) * sizeof(char*));
|
||||
for (Bit8u i = 0; i < count; i++) {
|
||||
#if !BX_PLUGINS
|
||||
net_module_names[i] = eth_locator_c::get_module_name(i);
|
||||
#else
|
||||
net_module_names[i] = PLUG_get_plugin_name(PLUGTYPE_NET, i);
|
||||
#endif
|
||||
}
|
||||
net_module_names[count] = NULL;
|
||||
}
|
||||
|
||||
const char **bx_netmod_ctl_c::get_module_names(void)
|
||||
{
|
||||
return net_module_names;
|
||||
}
|
||||
|
||||
void bx_netmod_ctl_c::list_modules(void)
|
||||
{
|
||||
char list[60];
|
||||
Bit8u i = 0;
|
||||
size_t len = 0, len1;
|
||||
|
||||
BX_INFO(("Networking modules"));
|
||||
list[0] = 0;
|
||||
while (net_module_names[i] != NULL) {
|
||||
len1 = strlen(net_module_names[i]);
|
||||
if ((len + len1 + 1) > 60) {
|
||||
BX_INFO((" %s", list));
|
||||
list[0] = 0;
|
||||
len = 0;
|
||||
}
|
||||
strcat(list, " ");
|
||||
strcat(list, net_module_names[i]);
|
||||
len = strlen(list);
|
||||
i++;
|
||||
}
|
||||
if (len > 0) {
|
||||
BX_INFO((" %s", list));
|
||||
}
|
||||
}
|
||||
|
||||
void bx_netmod_ctl_c::exit(void)
|
||||
{
|
||||
free(net_module_names);
|
||||
eth_locator_c::cleanup();
|
||||
}
|
||||
|
||||
@ -83,6 +131,7 @@ void* bx_netmod_ctl_c::init_module(bx_list_c *base, void *rxh, void *rxstat, bx_
|
||||
}
|
||||
|
||||
eth_locator_c *eth_locator_c::all;
|
||||
Bit8u eth_locator_c::count = 0;
|
||||
|
||||
//
|
||||
// Each pktmover module has a static locator class that registers
|
||||
@ -90,9 +139,18 @@ eth_locator_c *eth_locator_c::all;
|
||||
//
|
||||
eth_locator_c::eth_locator_c(const char *type)
|
||||
{
|
||||
next = all;
|
||||
all = this;
|
||||
eth_locator_c *ptr;
|
||||
|
||||
this->type = type;
|
||||
this->next = NULL;
|
||||
if (all == NULL) {
|
||||
all = this;
|
||||
} else {
|
||||
ptr = all;
|
||||
while (ptr->next) ptr = ptr->next;
|
||||
ptr->next = this;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
eth_locator_c::~eth_locator_c()
|
||||
@ -116,6 +174,24 @@ eth_locator_c::~eth_locator_c()
|
||||
}
|
||||
}
|
||||
|
||||
Bit8u eth_locator_c::get_modules_count()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
const char* eth_locator_c::get_module_name(Bit8u index)
|
||||
{
|
||||
eth_locator_c *ptr;
|
||||
Bit8u n = 0;
|
||||
|
||||
for (ptr = all; ptr != NULL; ptr = ptr->next) {
|
||||
if (n == index)
|
||||
return ptr->type;
|
||||
n++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool eth_locator_c::module_present(const char *type)
|
||||
{
|
||||
eth_locator_c *ptr = 0;
|
||||
|
@ -70,6 +70,8 @@ public:
|
||||
bx_netmod_ctl_c();
|
||||
virtual ~bx_netmod_ctl_c() {}
|
||||
void init(void);
|
||||
const char **get_module_names();
|
||||
void list_modules(void);
|
||||
void exit(void);
|
||||
virtual void* init_module(bx_list_c *base, void* rxh, void* rxstat, bx_devmodel_c *dev);
|
||||
};
|
||||
@ -117,6 +119,8 @@ protected:
|
||||
class BOCHSAPI_MSVCONLY eth_locator_c {
|
||||
public:
|
||||
static bool module_present(const char *type);
|
||||
static Bit8u get_modules_count(void);
|
||||
static const char* get_module_name(Bit8u index);
|
||||
static void cleanup();
|
||||
static eth_pktmover_c *create(const char *type, const char *netif,
|
||||
const char *macaddr,
|
||||
@ -134,6 +138,7 @@ protected:
|
||||
bx_devmodel_c *dev,
|
||||
const char *script) = 0;
|
||||
private:
|
||||
static Bit8u count;
|
||||
static eth_locator_c *all;
|
||||
eth_locator_c *next;
|
||||
const char *type;
|
||||
|
@ -28,6 +28,9 @@
|
||||
#include "cpu/cpu.h"
|
||||
#include "iodev/iodev.h"
|
||||
#include "iodev/hdimage/hdimage.h"
|
||||
#if BX_NETWORKING
|
||||
#include "iodev/network/netmod.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
@ -1272,8 +1275,8 @@ void bx_init_hardware()
|
||||
BX_INFO((" Handlers Chaining speedups: %s", BX_SUPPORT_HANDLERS_CHAINING_SPEEDUPS?"yes":"no"));
|
||||
BX_INFO(("Devices configuration"));
|
||||
BX_INFO((" PCI support: %s", BX_SUPPORT_PCI?"i440FX i430FX i440BX":"no"));
|
||||
#if BX_SUPPORT_NE2K || BX_SUPPORT_E1000
|
||||
BX_INFO((" Networking support:%s%s",
|
||||
#if BX_NETWORKING
|
||||
BX_INFO((" Network devices support:%s%s",
|
||||
BX_SUPPORT_NE2K?" NE2000":"", BX_SUPPORT_E1000?" E1000":""));
|
||||
#else
|
||||
BX_INFO((" Networking: no"));
|
||||
@ -1294,7 +1297,9 @@ void bx_init_hardware()
|
||||
BX_INFO((" VGA extension support: vbe%s%s",
|
||||
BX_SUPPORT_CLGD54XX?" cirrus":"", BX_SUPPORT_VOODOO?" voodoo":""));
|
||||
bx_hdimage_ctl.list_modules();
|
||||
|
||||
#if BX_NETWORKING
|
||||
bx_netmod_ctl.list_modules();
|
||||
#endif
|
||||
// Check if there is a romimage
|
||||
if (SIM->get_param_string(BXPN_ROM_PATH)->isempty()) {
|
||||
BX_ERROR(("No romimage to load. Is your bochsrc file loaded/valid ?"));
|
||||
|
Loading…
Reference in New Issue
Block a user