- added check for bochsrc options of optional plugins that have been moved to

the device code. Added panic message to force the user to enable the plugin
  with 'plugin_ctrl'.
- moved config parameter creation and bochsrc option parsing for device
  'usb_xhci' to the plugin device code
- added minimal documentation for the "log action per device" feature
- added log function name for 'usb_xhci'
This commit is contained in:
Volker Ruppert 2012-01-07 14:14:53 +00:00
parent bb9a1f45da
commit a48ef5f719
7 changed files with 149 additions and 80 deletions

View File

@ -8,7 +8,7 @@
# 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', 'speaker' and 'unmapped'.
# 'extfpuirq', 'gameport', 'iodebug', 'speaker', 'unmapped' and 'usb_xhci'.
#=======================================================================
#plugin_ctrl: unmapped=1, biosdev=1, speaker=1, e1000=1
@ -597,9 +597,13 @@ log: bochsout.txt
# debug: messages useful only when debugging the code. This may
# spit out thousands per second.
#
# For events of each level, you can choose to crash, report, or ignore.
# TODO: allow choice based on the facility: e.g. crash on panics from
# everything except the cdrom, and only report those.
# For events of each level, you can choose to exit Bochs ('fatal'), 'report'
# or 'ignore'. On some guis you have the additional choice 'ask'. A gui dialog
# appears asks how to proceed.
#
# It is also possible to specify the 'action' to do for each Bochs facility
# separately (e.g. crash on panics from everything except the cdrom, and only
# report those). TODO: add 'log function' module list to the user documentation.
#
# If you are experiencing many panics, it can be helpful to change
# the panic action to report instead of fatal. However, be aware
@ -610,7 +614,7 @@ log: bochsout.txt
panic: action=ask
error: action=report
info: action=report
debug: action=ignore
debug: action=ignore, pci=report # report BX_DEBUG from module 'pci'
#=======================================================================
# DEBUGGER_LOG:

View File

@ -117,10 +117,14 @@ char *bx_find_bochsrc(void);
int bx_parse_cmdline(int arg, int argc, char *argv[]);
int bx_read_configuration(const char *rcfile);
int bx_write_configuration(const char *rcfile, int overwrite);
void bx_init_std_nic_options(const char *name, bx_list_c *menu);
int bx_write_pci_nic_options(FILE *fp, bx_list_c *base);
int bx_parse_nic_params(const char *context, const char *param, bx_list_c *base);
void bx_reset_options(void);
// special config parameter and options functions for plugins
void bx_init_std_nic_options(const char *name, bx_list_c *menu);
int bx_parse_nic_params(const char *context, const char *param, bx_list_c *base);
int bx_parse_usb_port_params(const char *context, bx_bool devopt,
const char *param, int maxports, bx_list_c *base);
int bx_write_pci_nic_options(FILE *fp, bx_list_c *base);
int bx_write_usb_options(FILE *fp, int maxports, bx_list_c *base);
Bit32u crc32(const Bit8u *buf, int len);
// for param-tree testing only
void print_tree(bx_param_c *node, int level = 0);

View File

@ -1521,35 +1521,6 @@ void bx_init_options()
}
enabled->set_dependent_list(deplist);
// xHCI options
strcpy(group, "USB xHCI");
menu = new bx_list_c(usb, "xhci", "xHCI Configuration");
menu->set_options(menu->SHOW_PARENT);
menu->set_enabled(BX_SUPPORT_USB_XHCI);
enabled = new bx_param_bool_c(menu,
"enabled",
"Enable xHCI emulation",
"Enables the xHCI emulation",
0);
enabled->set_enabled(BX_SUPPORT_USB_XHCI);
deplist = new bx_list_c(NULL, BX_N_USB_XHCI_PORTS * 3);
for (i=0; i<BX_N_USB_XHCI_PORTS; i++) {
sprintf(name, "port%d", i+1);
sprintf(label, "Port #%d Configuration", i+1);
sprintf(descr, "Device connected to xHCI port #%d and it's options", i+1);
port = new bx_list_c(menu, name, label);
port->set_options(port->SERIES_ASK | port->USE_BOX_TITLE);
sprintf(descr, "Device connected to xHCI port #%d", i+1);
device = new bx_param_string_c(port, "device", "Device", descr, "", BX_PATHNAME_LEN);
sprintf(descr, "Options for device connected to xHCI port #%d", i+1);
options = new bx_param_string_c(port, "options", "Options", descr, "", BX_PATHNAME_LEN);
port->set_group(group);
deplist->add(port);
deplist->add(device);
deplist->add(options);
}
enabled->set_dependent_list(deplist);
// 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);
@ -2244,7 +2215,7 @@ static int parse_param_bool(const char *input, int len, const char *param)
return -1;
}
static int parse_usb_port_params(const char *context, bx_bool devopt, const char *param, int maxports, bx_list_c *base)
int bx_parse_usb_port_params(const char *context, bx_bool devopt, const char *param, int maxports, bx_list_c *base)
{
int idx, plen;
char tmpname[20];
@ -2304,6 +2275,33 @@ int bx_parse_nic_params(const char *context, const char *param, bx_list_c *base)
return valid;
}
// Check for optional plugins with add-on bochsrc options
// NOTE: This check should be removed some day
bx_bool is_optplugin_option(const char *param)
{
static const char *optplugin_list[] = {
#if BX_SUPPORT_E1000
"e1000",
#endif
#if BX_SUPPORT_ES1370
"es1370",
#endif
#if BX_SUPPORT_USB_XHCI
"usb_xhci",
#endif
NULL
};
int i = 0;
while (optplugin_list[i] != NULL) {
if (!strcmp(param, optplugin_list[i])) {
return 1;
}
i++;
}
return 0;
}
static int parse_line_formatted(const char *context, int num_params, char *params[])
{
int i, slot, t;
@ -3110,12 +3108,12 @@ static int parse_line_formatted(const char *context, int num_params, char *param
SIM->get_param_bool(BXPN_UHCI_ENABLED)->set(atol(&params[i][8]));
} else if (!strncmp(params[i], "port", 4)) {
base = (bx_list_c*) SIM->get_param("ports.usb.uhci");
if (parse_usb_port_params(context, 0, params[i], BX_N_USB_UHCI_PORTS, base) < 0) {
if (bx_parse_usb_port_params(context, 0, params[i], BX_N_USB_UHCI_PORTS, base) < 0) {
return -1;
}
} else if (!strncmp(params[i], "options", 7)) {
base = (bx_list_c*) SIM->get_param("ports.usb.uhci");
if (parse_usb_port_params(context, 1, params[i], BX_N_USB_UHCI_PORTS, base) < 0) {
if (bx_parse_usb_port_params(context, 1, params[i], BX_N_USB_UHCI_PORTS, base) < 0) {
return -1;
}
} else {
@ -3128,36 +3126,18 @@ static int parse_line_formatted(const char *context, int num_params, char *param
SIM->get_param_bool(BXPN_OHCI_ENABLED)->set(atol(&params[i][8]));
} else if (!strncmp(params[i], "port", 4)) {
base = (bx_list_c*) SIM->get_param("ports.usb.ohci");
if (parse_usb_port_params(context, 0, params[i], BX_N_USB_OHCI_PORTS, base) < 0) {
if (bx_parse_usb_port_params(context, 0, params[i], BX_N_USB_OHCI_PORTS, base) < 0) {
return -1;
}
} else if (!strncmp(params[i], "options", 7)) {
base = (bx_list_c*) SIM->get_param("ports.usb.ohci");
if (parse_usb_port_params(context, 1, params[i], BX_N_USB_OHCI_PORTS, base) < 0) {
if (bx_parse_usb_port_params(context, 1, params[i], BX_N_USB_OHCI_PORTS, base) < 0) {
return -1;
}
} else {
PARSE_WARN(("%s: unknown parameter '%s' for usb_ohci ignored.", context, params[i]));
}
}
} else if (!strcmp(params[0], "usb_xhci")) {
for (i=1; i<num_params; i++) {
if (!strncmp(params[i], "enabled=", 8)) {
SIM->get_param_bool(BXPN_XHCI_ENABLED)->set(atol(&params[i][8]));
} else if (!strncmp(params[i], "port", 4)) {
base = (bx_list_c*) SIM->get_param("ports.usb.xhci");
if (parse_usb_port_params(context, 0, params[i], BX_N_USB_XHCI_PORTS, base) < 0) {
return -1;
}
} else if (!strncmp(params[i], "options", 7)) {
base = (bx_list_c*) SIM->get_param("ports.usb.xhci");
if (parse_usb_port_params(context, 1, params[i], BX_N_USB_XHCI_PORTS, base) < 0) {
return -1;
}
} else {
PARSE_WARN(("%s: unknown parameter '%s' for usb_xhci ignored.", context, params[i]));
}
}
} else if ((!strcmp(params[0], "pci")) ||
(!strcmp(params[0], "i440fxsupport"))) {
// new option 'pci' for future extensions
@ -3550,11 +3530,16 @@ static int parse_line_formatted(const char *context, int num_params, char *param
free(param);
}
}
// user-defined options handled by registered functions
// add-on options handled by registered functions
else if (SIM->is_addon_option(params[0]))
{
return SIM->parse_addon_option(context, num_params, &params[0]);
}
// this check should force the user to enable the plugin
else if (is_optplugin_option(params[0]))
{
PARSE_ERR(("%s: directive '%s' requires to enable the plugin with 'plugin_ctrl'", context, params[0]));
}
else
{
PARSE_ERR(("%s: directive '%s' not understood", context, params[0]));
@ -3986,8 +3971,6 @@ int bx_write_configuration(const char *rc, int overwrite)
bx_write_usb_options(fp, BX_N_USB_UHCI_PORTS, base);
base = (bx_list_c*) SIM->get_param("ports.usb.ohci");
bx_write_usb_options(fp, BX_N_USB_OHCI_PORTS, base);
base = (bx_list_c*) SIM->get_param("ports.usb.xhci");
bx_write_usb_options(fp, BX_N_USB_XHCI_PORTS, base);
// pci
fprintf(fp, "pci: enabled=%d",
SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get());

View File

@ -228,11 +228,6 @@ void bx_devices_c::init(BX_MEM_C *newmem)
PLUG_load_plugin(usb_ohci, PLUGTYPE_OPTIONAL);
}
#endif
#if BX_SUPPORT_USB_XHCI
if (is_usb_xhci_enabled()) {
PLUG_load_plugin(usb_xhci, PLUGTYPE_OPTIONAL);
}
#endif
#if BX_SUPPORT_PCIDEV
if (SIM->get_param_num(BXPN_PCIDEV_VENDOR)->get() != 0xffff) {
PLUG_load_plugin(pcidev, PLUGTYPE_OPTIONAL);
@ -1043,14 +1038,6 @@ bx_bool bx_devices_c::is_usb_uhci_enabled(void)
return 0;
}
bx_bool bx_devices_c::is_usb_xhci_enabled(void)
{
if (SIM->get_param_bool(BXPN_XHCI_ENABLED)->get()) {
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

@ -594,7 +594,6 @@ private:
bx_bool is_parallel_enabled();
bx_bool is_usb_ohci_enabled();
bx_bool is_usb_uhci_enabled();
bx_bool is_usb_xhci_enabled();
};
// memory stub has an assumption that there are no memory accesses splitting 4K page

View File

@ -67,21 +67,102 @@ Bit8u port_band_width[4][1 + USB_XHCI_PORTS] = {
{ 0x00, 0x5A, 0x5A, 0x00, 0x00 } // 90%
};
// builtin configuration handling functions
void usb_xhci_init_options(void)
{
char name[BX_PATHNAME_LEN], descr[512], group[16], label[512];
bx_param_c *usb = SIM->get_param("ports.usb");
strcpy(group, "USB xHCI");
bx_list_c *menu = new bx_list_c(usb, "xhci", "xHCI Configuration");
menu->set_options(menu->SHOW_PARENT);
menu->set_enabled(BX_SUPPORT_USB_XHCI);
bx_param_bool_c *enabled = new bx_param_bool_c(menu,
"enabled",
"Enable xHCI emulation",
"Enables the xHCI emulation",
0);
enabled->set_enabled(BX_SUPPORT_USB_XHCI);
bx_list_c *deplist = new bx_list_c(NULL, BX_N_USB_XHCI_PORTS * 3);
for (int i = 0; i < BX_N_USB_XHCI_PORTS; i++) {
sprintf(name, "port%d", i+1);
sprintf(label, "Port #%d Configuration", i+1);
sprintf(descr, "Device connected to xHCI port #%d and it's options", i+1);
bx_list_c *port = new bx_list_c(menu, name, label);
port->set_options(port->SERIES_ASK | port->USE_BOX_TITLE);
sprintf(descr, "Device connected to xHCI port #%d", i+1);
bx_param_string_c *device = new bx_param_string_c(port, "device", "Device",
descr, "", BX_PATHNAME_LEN);
sprintf(descr, "Options for device connected to xHCI port #%d", i+1);
bx_param_string_c *options = new bx_param_string_c(port, "options", "Options",
descr, "", BX_PATHNAME_LEN);
port->set_group(group);
deplist->add(port);
deplist->add(device);
deplist->add(options);
}
enabled->set_dependent_list(deplist);
}
Bit32s usb_xhci_options_parser(const char *context, int num_params, char *params[])
{
if (!strcmp(params[0], "usb_xhci")) {
bx_list_c *base = (bx_list_c*) SIM->get_param(BXPN_USB_XHCI);
for (int i = 1; i < num_params; i++) {
if (!strncmp(params[i], "enabled=", 8)) {
SIM->get_param_bool(BXPN_XHCI_ENABLED)->set(atol(&params[i][8]));
} else if (!strncmp(params[i], "port", 4)) {
if (bx_parse_usb_port_params(context, 0, params[i], BX_N_USB_XHCI_PORTS, base) < 0) {
return -1;
}
} else if (!strncmp(params[i], "options", 7)) {
if (bx_parse_usb_port_params(context, 1, params[i], BX_N_USB_XHCI_PORTS, base) < 0) {
return -1;
}
} else {
BX_ERROR(("%s: unknown parameter '%s' for usb_xhci ignored.", context, params[i]));
}
}
} else {
BX_PANIC(("%s: unknown directive '%s'", context, params[0]));
}
return 0;
}
Bit32s usb_xhci_options_save(FILE *fp)
{
bx_list_c *base = (bx_list_c*) SIM->get_param(BXPN_USB_XHCI);
bx_write_usb_options(fp, BX_N_USB_XHCI_PORTS, base);
return 0;
}
// device plugin entry points
int libusb_xhci_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
{
theUSB_XHCI = new bx_usb_xhci_c();
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theUSB_XHCI, BX_PLUGIN_USB_XHCI);
// add new configuration parameter for the config interface
usb_xhci_init_options();
// register add-on option for bochsrc and command line
SIM->register_addon_option("usb_xhci", usb_xhci_options_parser, usb_xhci_options_save);
return 0; // Success
}
void libusb_xhci_LTX_plugin_fini(void)
{
SIM->unregister_addon_option("usb_xhci");
bx_list_c *menu = (bx_list_c*)SIM->get_param("ports.usb");
menu->remove("usb_xhci");
delete theUSB_XHCI;
}
// the device object
bx_usb_xhci_c::bx_usb_xhci_c()
{
put("XHCI");
put("usb_xhci", "XHCI");
memset((void*)&hub, 0, sizeof(bx_usb_xhci_t));
device_buffer = NULL;
//hub.frame_timer_index = BX_NULL_TIMER_HANDLE;
@ -107,9 +188,18 @@ void bx_usb_xhci_c::init(void)
{
unsigned i;
char pname[6];
bx_list_c *port;
bx_list_c *xhci, *port;
bx_param_string_c *device, *options;
// Read in values from config interface
xhci = (bx_list_c*) SIM->get_param(BXPN_USB_XHCI);
// Check if the device is disabled or not configured
if (!SIM->get_param_bool("enabled", xhci)->get()) {
BX_INFO(("USB xHCI disabled"));
BX_UNREGISTER_DEVICE_DEVMODEL("usb_xhci");
return;
}
BX_XHCI_THIS device_buffer = new Bit8u[65536];
// TODO: Use this to decrement the Interrupter:count down value
@ -131,7 +221,6 @@ void bx_usb_xhci_c::init(void)
BX_XHCI_THIS hub.statusbar_id = bx_gui->register_statusitem("xHCI", 1);
bx_list_c *usb_rt = (bx_list_c*)SIM->get_param(BXPN_MENU_RUNTIME_USB);
bx_list_c *xhci = (bx_list_c*)SIM->get_param(BXPN_USB_XHCI);
xhci->set_options(xhci->SHOW_PARENT | xhci->USE_BOX_TITLE);
xhci->set_runtime_param(1);
usb_rt->add(xhci);

View File

@ -835,6 +835,9 @@ static builtin_plugin_t builtin_opt_plugins[] = {
#endif
#if BX_SUPPORT_ES1370
BUILTIN_PLUGIN_ENTRY(es1370),
#endif
#if BX_SUPPORT_USB_XHCI
BUILTIN_PLUGIN_ENTRY(usb_xhci),
#endif
{"NULL", NULL, NULL, 0}
};