Generate USB devices list from available USB plugins list and removed hardcoded
device handling. Added some code to handle plugins that provide more than one device type (usb_hid, usb_msd) or with different name (usb_cbi). The device type member is now only used by multi-function devices.
This commit is contained in:
parent
2ab50c7d66
commit
dcdceb96f6
@ -5,7 +5,8 @@ Changes after 2.6.11:
|
||||
- Improved plugins handling: all available plugins in path are detected at
|
||||
startup (including externally developed ones). These types are supported in
|
||||
Bochs configuration: display libraries, VGA compatile adapters, optional
|
||||
PCI/ISA devices, disk image, networking and sound driver modules.
|
||||
PCI/ISA devices, pluggable USB devices, disk image, networking and sound
|
||||
driver modules.
|
||||
- Save/Restore bugfixes
|
||||
- Removed legacy "load32bitOShack" feature.
|
||||
- Removed "svga" display library designed for the obsolete Linux SVGALib.
|
||||
|
@ -63,7 +63,7 @@ class bx_usb_cbi_locator_c : public usbdev_locator_c {
|
||||
public:
|
||||
bx_usb_cbi_locator_c(void) : usbdev_locator_c("usb_cbi") {}
|
||||
protected:
|
||||
usb_device_c *allocate(usbdev_type devtype) {
|
||||
usb_device_c *allocate(const char *devname) {
|
||||
return (new usb_cbi_device_c());
|
||||
}
|
||||
} bx_usb_cbi_match;
|
||||
@ -320,7 +320,6 @@ usb_cbi_device_c::usb_cbi_device_c()
|
||||
bx_param_bool_c *readonly;
|
||||
bx_param_enum_c *status, *mode;
|
||||
|
||||
d.type = USB_DEV_TYPE_FLOPPY;
|
||||
d.speed = d.minspeed = d.maxspeed = USB_SPEED_FULL;
|
||||
memset((void*)&s, 0, sizeof(s));
|
||||
strcpy(d.devname, "BOCHS USB CBI FLOPPY");
|
||||
|
@ -37,6 +37,10 @@
|
||||
|
||||
bx_usbdev_ctl_c bx_usbdev_ctl;
|
||||
|
||||
const char **usb_module_names;
|
||||
const char **usb_device_names;
|
||||
Bit8u *usb_module_id;
|
||||
|
||||
bx_usbdev_ctl_c::bx_usbdev_ctl_c()
|
||||
{
|
||||
put("usbdevctl", "USBCTL");
|
||||
@ -44,40 +48,55 @@ bx_usbdev_ctl_c::bx_usbdev_ctl_c()
|
||||
|
||||
void bx_usbdev_ctl_c::init(void)
|
||||
{
|
||||
// TODO
|
||||
Bit8u i, j, count;
|
||||
|
||||
count = PLUG_get_plugins_count(PLUGTYPE_USB);
|
||||
usb_module_names = (const char**) malloc(count * sizeof(char*));
|
||||
usb_device_names = (const char**) malloc((count + 5) * sizeof(char*));
|
||||
usb_module_id = (Bit8u*) malloc((count + 5) * sizeof(Bit8u));
|
||||
usb_device_names[0] = "none";
|
||||
usb_module_id[0] = 0xff;
|
||||
j = 1;
|
||||
for (i = 0; i < count; i++) {
|
||||
usb_module_names[i] = PLUG_get_plugin_name(PLUGTYPE_USB, i);
|
||||
if (!strcmp(usb_module_names[i], "usb_hid")) {
|
||||
usb_device_names[j] = "mouse";
|
||||
usb_module_id[j++] = i;
|
||||
usb_device_names[j] = "tablet";
|
||||
usb_module_id[j++] = i;
|
||||
usb_device_names[j] = "keypad";
|
||||
usb_module_id[j++] = i;
|
||||
usb_device_names[j] = "keyboard";
|
||||
usb_module_id[j] = i;
|
||||
} else if (!strcmp(usb_module_names[i], "usb_msd")) {
|
||||
usb_device_names[j] = "disk";
|
||||
usb_module_id[j++] = i;
|
||||
usb_device_names[j] = "cdrom";
|
||||
usb_module_id[j] = i;
|
||||
} else if (!strcmp(usb_module_names[i], "usb_cbi")) {
|
||||
usb_device_names[j] = "floppy";
|
||||
usb_module_id[j] = i;
|
||||
} else {
|
||||
if (!strncmp(usb_module_names[i], "usb_", 4)) {
|
||||
usb_device_names[j] = &usb_module_names[i][4];
|
||||
} else {
|
||||
usb_device_names[j] = usb_module_names[i];
|
||||
}
|
||||
usb_module_id[j] = i;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
usb_device_names[j] = NULL;
|
||||
}
|
||||
|
||||
void bx_usbdev_ctl_c::exit(void)
|
||||
{
|
||||
// TODO
|
||||
free(usb_module_names);
|
||||
free(usb_device_names);
|
||||
free(usb_module_id);
|
||||
usbdev_locator_c::cleanup();
|
||||
}
|
||||
|
||||
const char *usbmod_names[] =
|
||||
{
|
||||
"none",
|
||||
"usb_cbi",
|
||||
"usb_hid",
|
||||
"usb_hub",
|
||||
"usb_msd",
|
||||
"usb_printer"
|
||||
};
|
||||
|
||||
const char *usb_device_names[] =
|
||||
{
|
||||
"none",
|
||||
"mouse",
|
||||
"tablet",
|
||||
"keypad",
|
||||
"keyboard",
|
||||
"disk",
|
||||
"cdrom",
|
||||
"hub",
|
||||
"printer",
|
||||
"floppy",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char **bx_usbdev_ctl_c::get_device_names(void)
|
||||
{
|
||||
return usb_device_names;
|
||||
@ -110,48 +129,16 @@ void bx_usbdev_ctl_c::list_devices(void)
|
||||
|
||||
bool bx_usbdev_ctl_c::init_device(bx_list_c *portconf, logfunctions *hub, void **dev)
|
||||
{
|
||||
usbmod_type modtype = USB_MOD_TYPE_NONE;
|
||||
usbdev_type devtype = USB_DEV_TYPE_NONE;
|
||||
Bit8u devtype, modtype;
|
||||
usb_device_c **device = (usb_device_c**)dev;
|
||||
const char *devname, *options, *options2;
|
||||
const char *options, *options2;
|
||||
char new_options[BX_PATHNAME_LEN];
|
||||
bx_param_string_c *opts2;
|
||||
|
||||
devname = ((bx_param_enum_c*)portconf->get_by_name("device"))->get_selected();
|
||||
devtype = (Bit8u)((bx_param_enum_c*)portconf->get_by_name("device"))->get();
|
||||
modtype = usb_module_id[devtype];
|
||||
options = ((bx_param_string_c*)portconf->get_by_name("options"))->getptr();
|
||||
opts2 = (bx_param_string_c*)portconf->get_by_name("options2");
|
||||
if (!strcmp(devname, "mouse")) {
|
||||
modtype = USB_MOD_TYPE_HID;
|
||||
devtype = USB_DEV_TYPE_MOUSE;
|
||||
} else if (!strcmp(devname, "tablet")) {
|
||||
modtype = USB_MOD_TYPE_HID;
|
||||
devtype = USB_DEV_TYPE_TABLET;
|
||||
} else if (!strcmp(devname, "keypad")) {
|
||||
modtype = USB_MOD_TYPE_HID;
|
||||
devtype = USB_DEV_TYPE_KEYPAD;
|
||||
} else if (!strcmp(devname, "keyboard")) {
|
||||
modtype = USB_MOD_TYPE_HID;
|
||||
devtype = USB_DEV_TYPE_KEYBOARD;
|
||||
} else if (!strcmp(devname, "disk")) {
|
||||
modtype = USB_MOD_TYPE_MSD;
|
||||
devtype = USB_DEV_TYPE_DISK;
|
||||
} else if (!strcmp(devname, "cdrom")) {
|
||||
modtype = USB_MOD_TYPE_MSD;
|
||||
devtype = USB_DEV_TYPE_CDROM;
|
||||
} else if (!strcmp(devname, "hub")) {
|
||||
modtype = USB_MOD_TYPE_HUB;
|
||||
devtype = USB_DEV_TYPE_HUB;
|
||||
} else if (!strcmp(devname, "printer")) {
|
||||
modtype = USB_MOD_TYPE_PRINTER;
|
||||
devtype = USB_DEV_TYPE_PRINTER;
|
||||
} else if (!strncmp(devname, "floppy", 6)) {
|
||||
modtype = USB_MOD_TYPE_CBI;
|
||||
devtype = USB_DEV_TYPE_FLOPPY;
|
||||
} else {
|
||||
hub->panic("unknown USB device: %s", devname);
|
||||
delete [] devname;
|
||||
return devtype;
|
||||
}
|
||||
if (opts2 != NULL) {
|
||||
// backward compatibility code
|
||||
options2 = opts2->getptr();
|
||||
@ -163,14 +150,15 @@ bool bx_usbdev_ctl_c::init_device(bx_list_c *portconf, logfunctions *hub, void *
|
||||
((bx_param_string_c*)portconf->get_by_name("options"))->set(new_options);
|
||||
portconf->remove("options2");
|
||||
}
|
||||
if (!usbdev_locator_c::module_present(usbmod_names[modtype])) {
|
||||
if (!usbdev_locator_c::module_present(usb_module_names[modtype])) {
|
||||
#if BX_PLUGINS
|
||||
PLUG_load_plugin_var(usbmod_names[modtype], PLUGTYPE_USB);
|
||||
PLUG_load_plugin_var(usb_module_names[modtype], PLUGTYPE_USB);
|
||||
#else
|
||||
BX_PANIC(("could not find USB device '%s'", usbmod_names[modtype]));
|
||||
BX_PANIC(("could not find USB module '%s'", usb_module_names[modtype]));
|
||||
#endif
|
||||
}
|
||||
*device = usbdev_locator_c::create(usbmod_names[modtype], devtype);
|
||||
*device = usbdev_locator_c::create(usb_module_names[modtype],
|
||||
usb_device_names[devtype]);
|
||||
if (*device != NULL) {
|
||||
parse_port_options(*device, portconf);
|
||||
}
|
||||
@ -181,9 +169,11 @@ void bx_usbdev_ctl_c::parse_port_options(usb_device_c *device, bx_list_c *portco
|
||||
{
|
||||
const char *raw_options;
|
||||
int i, optc, speed = USB_SPEED_LOW; // assume LOW speed device if parameter not given.
|
||||
Bit8u devtype;
|
||||
char *opts[16];
|
||||
|
||||
memset(opts, 0, sizeof(opts));
|
||||
devtype = ((bx_param_enum_c*)portconf->get_by_name("device"))->get();
|
||||
raw_options = ((bx_param_string_c*)portconf->get_by_name("options"))->getptr();
|
||||
optc = bx_split_option_list("USB port options", raw_options, opts, 16);
|
||||
for (i = 0; i < optc; i++) {
|
||||
@ -201,7 +191,7 @@ void bx_usbdev_ctl_c::parse_port_options(usb_device_c *device, bx_list_c *portco
|
||||
}
|
||||
if (!device->set_speed(speed)) {
|
||||
BX_PANIC(("USB device '%s' doesn't support '%s' speed",
|
||||
usb_device_names[device->get_type()], opts[i]+6));
|
||||
usb_device_names[devtype], opts[i]+6));
|
||||
}
|
||||
} else if (!strcmp(opts[i], "debug")) {
|
||||
device->set_debug_mode();
|
||||
@ -275,13 +265,13 @@ void usbdev_locator_c::cleanup()
|
||||
// Called by USB HC emulations to locate and create a usb_device_c
|
||||
// object
|
||||
//
|
||||
usb_device_c* usbdev_locator_c::create(const char *type, usbdev_type devtype)
|
||||
usb_device_c* usbdev_locator_c::create(const char *type, const char *devname)
|
||||
{
|
||||
usbdev_locator_c *ptr = 0;
|
||||
|
||||
for (ptr = all; ptr != NULL; ptr = ptr->next) {
|
||||
if (strcmp(type, ptr->type) == 0)
|
||||
return (ptr->allocate(devtype));
|
||||
return (ptr->allocate(devname));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -146,28 +146,6 @@ typedef struct USBAsync {
|
||||
struct USBAsync *next;
|
||||
} USBAsync;
|
||||
|
||||
enum usbmod_type {
|
||||
USB_MOD_TYPE_NONE=0,
|
||||
USB_MOD_TYPE_CBI,
|
||||
USB_MOD_TYPE_HID,
|
||||
USB_MOD_TYPE_HUB,
|
||||
USB_MOD_TYPE_MSD,
|
||||
USB_MOD_TYPE_PRINTER
|
||||
};
|
||||
|
||||
enum usbdev_type {
|
||||
USB_DEV_TYPE_NONE=0,
|
||||
USB_DEV_TYPE_MOUSE,
|
||||
USB_DEV_TYPE_TABLET,
|
||||
USB_DEV_TYPE_KEYPAD,
|
||||
USB_DEV_TYPE_KEYBOARD,
|
||||
USB_DEV_TYPE_DISK,
|
||||
USB_DEV_TYPE_CDROM,
|
||||
USB_DEV_TYPE_HUB,
|
||||
USB_DEV_TYPE_PRINTER,
|
||||
USB_DEV_TYPE_FLOPPY
|
||||
};
|
||||
|
||||
class BOCHSAPI bx_usbdev_ctl_c : public logfunctions {
|
||||
public:
|
||||
bx_usbdev_ctl_c();
|
||||
@ -182,7 +160,6 @@ private:
|
||||
};
|
||||
|
||||
BOCHSAPI extern bx_usbdev_ctl_c bx_usbdev_ctl;
|
||||
BOCHSAPI extern const char *usb_device_names[];
|
||||
|
||||
class BOCHSAPI usb_device_c : public logfunctions {
|
||||
public:
|
||||
@ -205,7 +182,6 @@ public:
|
||||
virtual void runtime_config() {}
|
||||
|
||||
bool get_connected() {return d.connected;}
|
||||
int get_type() {return (int)d.type;}
|
||||
int get_speed() {return d.speed;}
|
||||
bool set_speed(int speed)
|
||||
{
|
||||
@ -231,7 +207,7 @@ public:
|
||||
|
||||
protected:
|
||||
struct {
|
||||
enum usbdev_type type;
|
||||
Bit8u type;
|
||||
bool connected;
|
||||
int minspeed;
|
||||
int maxspeed;
|
||||
@ -389,11 +365,11 @@ class BOCHSAPI_MSVCONLY usbdev_locator_c {
|
||||
public:
|
||||
static bool module_present(const char *type);
|
||||
static void cleanup();
|
||||
static usb_device_c *create(const char *type, usbdev_type devtype);
|
||||
static usb_device_c *create(const char *type, const char *devname);
|
||||
protected:
|
||||
usbdev_locator_c(const char *type);
|
||||
virtual ~usbdev_locator_c();
|
||||
virtual usb_device_c *allocate(usbdev_type devtype) = 0;
|
||||
virtual usb_device_c *allocate(const char *devname) = 0;
|
||||
private:
|
||||
static usbdev_locator_c *all;
|
||||
usbdev_locator_c *next;
|
||||
|
@ -78,11 +78,17 @@ class bx_usb_hid_locator_c : public usbdev_locator_c {
|
||||
public:
|
||||
bx_usb_hid_locator_c(void) : usbdev_locator_c("usb_hid") {}
|
||||
protected:
|
||||
usb_device_c *allocate(usbdev_type devtype) {
|
||||
usb_device_c *allocate(const char *devtype) {
|
||||
return (new usb_hid_device_c(devtype));
|
||||
}
|
||||
} bx_usb_hid_match;
|
||||
|
||||
/* supported HID device types */
|
||||
#define USB_HID_TYPE_MOUSE 0
|
||||
#define USB_HID_TYPE_TABLET 1
|
||||
#define USB_HID_TYPE_KEYPAD 2
|
||||
#define USB_HID_TYPE_KEYBOARD 3
|
||||
|
||||
/* HID IDLE time constant */
|
||||
#define HID_IDLE_TIME 4000
|
||||
|
||||
@ -682,27 +688,35 @@ struct USBKBD usbkbd_conv[BX_KEY_NBKEYS] = {
|
||||
0x00, 0 /* BX_KEY_WAKE */
|
||||
};
|
||||
|
||||
usb_hid_device_c::usb_hid_device_c(usbdev_type type)
|
||||
usb_hid_device_c::usb_hid_device_c(const char *devname)
|
||||
{
|
||||
d.type = type;
|
||||
if (!strcmp(devname, "mouse")) {
|
||||
d.type = USB_HID_TYPE_MOUSE;
|
||||
} else if (!strcmp(devname, "tablet")) {
|
||||
d.type = USB_HID_TYPE_TABLET;
|
||||
} else if (!strcmp(devname, "keypad")) {
|
||||
d.type = USB_HID_TYPE_KEYPAD;
|
||||
} else {
|
||||
d.type = USB_HID_TYPE_KEYBOARD;
|
||||
}
|
||||
d.minspeed = USB_SPEED_LOW;
|
||||
d.maxspeed = USB_SPEED_HIGH;
|
||||
d.speed = d.minspeed;
|
||||
if (d.type == USB_DEV_TYPE_MOUSE) {
|
||||
if (d.type == USB_HID_TYPE_MOUSE) {
|
||||
strcpy(d.devname, "USB Mouse");
|
||||
DEV_register_removable_mouse((void*)this, mouse_enq_static, mouse_enabled_changed);
|
||||
} else if (d.type == USB_DEV_TYPE_TABLET) {
|
||||
} else if (d.type == USB_HID_TYPE_TABLET) {
|
||||
strcpy(d.devname, "USB Tablet");
|
||||
DEV_register_removable_mouse((void*)this, mouse_enq_static, mouse_enabled_changed);
|
||||
bx_gui->set_mouse_mode_absxy(1);
|
||||
} else if ((d.type == USB_DEV_TYPE_KEYPAD) || (d.type == USB_DEV_TYPE_KEYBOARD)) {
|
||||
} else if ((d.type == USB_HID_TYPE_KEYPAD) || (d.type == USB_HID_TYPE_KEYBOARD)) {
|
||||
Bit8u led_mask;
|
||||
if (d.type == USB_DEV_TYPE_KEYPAD) {
|
||||
if (d.type == USB_HID_TYPE_KEYPAD) {
|
||||
strcpy(d.devname, "USB/PS2 Keypad");
|
||||
} else {
|
||||
strcpy(d.devname, "USB/PS2 Keyboard");
|
||||
}
|
||||
if (d.type == USB_DEV_TYPE_KEYPAD) {
|
||||
if (d.type == USB_HID_TYPE_KEYPAD) {
|
||||
led_mask = BX_KBD_LED_MASK_NUM;
|
||||
} else {
|
||||
led_mask = BX_KBD_LED_MASK_ALL;
|
||||
@ -723,12 +737,12 @@ usb_hid_device_c::usb_hid_device_c(usbdev_type type)
|
||||
usb_hid_device_c::~usb_hid_device_c(void)
|
||||
{
|
||||
d.sr->clear();
|
||||
if ((d.type == USB_DEV_TYPE_MOUSE) ||
|
||||
(d.type == USB_DEV_TYPE_TABLET)) {
|
||||
if ((d.type == USB_HID_TYPE_MOUSE) ||
|
||||
(d.type == USB_HID_TYPE_TABLET)) {
|
||||
bx_gui->set_mouse_mode_absxy(0);
|
||||
DEV_unregister_removable_mouse((void*)this);
|
||||
} else if ((d.type == USB_DEV_TYPE_KEYPAD) ||
|
||||
(d.type == USB_DEV_TYPE_KEYBOARD)) {
|
||||
} else if ((d.type == USB_HID_TYPE_KEYPAD) ||
|
||||
(d.type == USB_HID_TYPE_KEYBOARD)) {
|
||||
DEV_unregister_removable_keyboard((void*)this);
|
||||
}
|
||||
bx_pc_system.unregisterTimer(timer_index);
|
||||
@ -736,8 +750,8 @@ usb_hid_device_c::~usb_hid_device_c(void)
|
||||
|
||||
bool usb_hid_device_c::init()
|
||||
{
|
||||
if ((d.type == USB_DEV_TYPE_MOUSE) ||
|
||||
(d.type == USB_DEV_TYPE_TABLET)) {
|
||||
if ((d.type == USB_HID_TYPE_MOUSE) ||
|
||||
(d.type == USB_HID_TYPE_TABLET)) {
|
||||
if (d.speed == USB_SPEED_HIGH) {
|
||||
d.dev_descriptor = bx_mouse_dev_descriptor2;
|
||||
d.device_desc_size = sizeof(bx_mouse_dev_descriptor2);
|
||||
@ -745,7 +759,7 @@ bool usb_hid_device_c::init()
|
||||
d.dev_descriptor = bx_mouse_dev_descriptor;
|
||||
d.device_desc_size = sizeof(bx_mouse_dev_descriptor);
|
||||
}
|
||||
if (d.type == USB_DEV_TYPE_MOUSE) {
|
||||
if (d.type == USB_HID_TYPE_MOUSE) {
|
||||
if (d.speed == USB_SPEED_HIGH) {
|
||||
d.config_descriptor = bx_mouse_config_descriptor2;
|
||||
d.config_desc_size = sizeof(bx_mouse_config_descriptor2);
|
||||
@ -797,7 +811,7 @@ void usb_hid_device_c::register_state_specific(bx_list_c *parent)
|
||||
BXRS_HEX_PARAM_FIELD(list, b_state, s.b_state);
|
||||
BXRS_DEC_PARAM_FIELD(list, mouse_event_count, s.mouse_event_count);
|
||||
new bx_shadow_data_c(list, "mouse_event_buf", (Bit8u*)s.mouse_event_buf, 6 * BX_KBD_ELEMENTS, 1);
|
||||
if ((d.type == USB_DEV_TYPE_KEYPAD) || (d.type == USB_DEV_TYPE_KEYBOARD)) {
|
||||
if ((d.type == USB_HID_TYPE_KEYPAD) || (d.type == USB_HID_TYPE_KEYBOARD)) {
|
||||
new bx_shadow_data_c(list, "kbd_packet", s.kbd_packet, 8, 1);
|
||||
BXRS_HEX_PARAM_FIELD(list, indicators, s.indicators);
|
||||
BXRS_DEC_PARAM_FIELD(list, kbd_event_count, s.kbd_event_count);
|
||||
@ -858,16 +872,16 @@ int usb_hid_device_c::handle_control(int request, int value, int index, int leng
|
||||
case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
switch(value >> 8) {
|
||||
case 0x21:
|
||||
if (d.type == USB_DEV_TYPE_MOUSE) {
|
||||
if (d.type == USB_HID_TYPE_MOUSE) {
|
||||
memcpy(data, bx_mouse_hid_descriptor,
|
||||
sizeof(bx_mouse_hid_descriptor));
|
||||
ret = sizeof(bx_mouse_hid_descriptor);
|
||||
} else if (d.type == USB_DEV_TYPE_TABLET) {
|
||||
} else if (d.type == USB_HID_TYPE_TABLET) {
|
||||
memcpy(data, bx_tablet_hid_descriptor,
|
||||
sizeof(bx_tablet_hid_descriptor));
|
||||
ret = sizeof(bx_tablet_hid_descriptor);
|
||||
} else if ((d.type == USB_DEV_TYPE_KEYPAD) ||
|
||||
(d.type == USB_DEV_TYPE_KEYBOARD)) {
|
||||
} else if ((d.type == USB_HID_TYPE_KEYPAD) ||
|
||||
(d.type == USB_HID_TYPE_KEYBOARD)) {
|
||||
memcpy(data, bx_keypad_hid_descriptor,
|
||||
sizeof(bx_keypad_hid_descriptor));
|
||||
ret = sizeof(bx_keypad_hid_descriptor);
|
||||
@ -876,16 +890,16 @@ int usb_hid_device_c::handle_control(int request, int value, int index, int leng
|
||||
}
|
||||
break;
|
||||
case 0x22:
|
||||
if (d.type == USB_DEV_TYPE_MOUSE) {
|
||||
if (d.type == USB_HID_TYPE_MOUSE) {
|
||||
memcpy(data, bx_mouse_hid_report_descriptor,
|
||||
sizeof(bx_mouse_hid_report_descriptor));
|
||||
ret = sizeof(bx_mouse_hid_report_descriptor);
|
||||
} else if (d.type == USB_DEV_TYPE_TABLET) {
|
||||
} else if (d.type == USB_HID_TYPE_TABLET) {
|
||||
memcpy(data, bx_tablet_hid_report_descriptor,
|
||||
sizeof(bx_tablet_hid_report_descriptor));
|
||||
ret = sizeof(bx_tablet_hid_report_descriptor);
|
||||
} else if ((d.type == USB_DEV_TYPE_KEYPAD) ||
|
||||
(d.type == USB_DEV_TYPE_KEYBOARD)) {
|
||||
} else if ((d.type == USB_HID_TYPE_KEYPAD) ||
|
||||
(d.type == USB_HID_TYPE_KEYBOARD)) {
|
||||
memcpy(data, bx_keypad_hid_report_descriptor,
|
||||
sizeof(bx_keypad_hid_report_descriptor));
|
||||
ret = sizeof(bx_keypad_hid_report_descriptor);
|
||||
@ -907,25 +921,25 @@ int usb_hid_device_c::handle_control(int request, int value, int index, int leng
|
||||
}
|
||||
break;
|
||||
case GET_REPORT:
|
||||
if ((d.type == USB_DEV_TYPE_MOUSE) ||
|
||||
(d.type == USB_DEV_TYPE_TABLET)) {
|
||||
if ((d.type == USB_HID_TYPE_MOUSE) ||
|
||||
(d.type == USB_HID_TYPE_TABLET)) {
|
||||
ret = mouse_poll(data, length, 1);
|
||||
} else if ((d.type == USB_DEV_TYPE_KEYPAD) ||
|
||||
(d.type == USB_DEV_TYPE_KEYBOARD)) {
|
||||
} else if ((d.type == USB_HID_TYPE_KEYPAD) ||
|
||||
(d.type == USB_HID_TYPE_KEYBOARD)) {
|
||||
ret = keyboard_poll(data, length, 1);
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case SET_REPORT:
|
||||
if (((d.type == USB_DEV_TYPE_KEYPAD) ||
|
||||
(d.type == USB_DEV_TYPE_KEYBOARD)) && (value = 0x200)) {
|
||||
if (((d.type == USB_HID_TYPE_KEYPAD) ||
|
||||
(d.type == USB_HID_TYPE_KEYBOARD)) && (value = 0x200)) {
|
||||
modchange = (data[0] ^ s.indicators);
|
||||
if (modchange != 0) {
|
||||
if (modchange & 0x01) {
|
||||
DEV_kbd_set_indicator(1, BX_KBD_LED_NUM, data[0] & 0x01);
|
||||
BX_DEBUG(("NUM_LOCK %s", (data[0] & 0x01) ? "on" : "off"));
|
||||
} else if (d.type == USB_DEV_TYPE_KEYBOARD) {
|
||||
} else if (d.type == USB_HID_TYPE_KEYBOARD) {
|
||||
if (modchange & 0x02) {
|
||||
DEV_kbd_set_indicator(1, BX_KBD_LED_CAPS, data[0] & 0x02);
|
||||
BX_DEBUG(("CAPS_LOCK %s", (data[0] & 0x02) ? "on" : "off"));
|
||||
@ -970,11 +984,11 @@ int usb_hid_device_c::handle_data(USBPacket *p)
|
||||
switch(p->pid) {
|
||||
case USB_TOKEN_IN:
|
||||
if (p->devep == 1) {
|
||||
if ((d.type == USB_DEV_TYPE_MOUSE) ||
|
||||
(d.type == USB_DEV_TYPE_TABLET)) {
|
||||
if ((d.type == USB_HID_TYPE_MOUSE) ||
|
||||
(d.type == USB_HID_TYPE_TABLET)) {
|
||||
ret = mouse_poll(p->data, p->len, 0);
|
||||
} else if ((d.type == USB_DEV_TYPE_KEYPAD) ||
|
||||
(d.type == USB_DEV_TYPE_KEYBOARD)) {
|
||||
} else if ((d.type == USB_HID_TYPE_KEYPAD) ||
|
||||
(d.type == USB_HID_TYPE_KEYBOARD)) {
|
||||
ret = keyboard_poll(p->data, p->len, 0);
|
||||
} else {
|
||||
goto fail;
|
||||
@ -998,7 +1012,7 @@ int usb_hid_device_c::mouse_poll(Bit8u *buf, int len, bool force)
|
||||
{
|
||||
int l = USB_RET_NAK;
|
||||
|
||||
if (d.type == USB_DEV_TYPE_MOUSE) {
|
||||
if (d.type == USB_HID_TYPE_MOUSE) {
|
||||
if (!s.has_events) {
|
||||
// if there's no new movement, handle delayed one
|
||||
mouse_enq(0, 0, s.mouse_z, s.b_state, 0);
|
||||
@ -1012,7 +1026,7 @@ int usb_hid_device_c::mouse_poll(Bit8u *buf, int len, bool force)
|
||||
s.has_events = (s.mouse_event_count > 0);
|
||||
start_idle_timer();
|
||||
}
|
||||
} else if (d.type == USB_DEV_TYPE_TABLET) {
|
||||
} else if (d.type == USB_HID_TYPE_TABLET) {
|
||||
if (s.has_events || force) {
|
||||
if (s.mouse_event_count > 0) {
|
||||
l = get_mouse_packet(buf, len);
|
||||
@ -1030,7 +1044,7 @@ int usb_hid_device_c::create_mouse_packet(Bit8u *buf, int len)
|
||||
{
|
||||
int l;
|
||||
|
||||
if (d.type == USB_DEV_TYPE_TABLET) {
|
||||
if (d.type == USB_HID_TYPE_TABLET) {
|
||||
buf[0] = (Bit8u) s.b_state;
|
||||
buf[1] = (Bit8u)(s.mouse_x & 0xff);
|
||||
buf[2] = (Bit8u)(s.mouse_x >> 8);
|
||||
@ -1059,7 +1073,7 @@ int usb_hid_device_c::get_mouse_packet(Bit8u *buf, int len)
|
||||
int l = USB_RET_NAK;
|
||||
|
||||
if (s.mouse_event_count > 0) {
|
||||
if (d.type == USB_DEV_TYPE_TABLET) {
|
||||
if (d.type == USB_HID_TYPE_TABLET) {
|
||||
l = 6;
|
||||
} else if (len >= 4) {
|
||||
l = 4;
|
||||
@ -1089,7 +1103,7 @@ void usb_hid_device_c::mouse_enq(int delta_x, int delta_y, int delta_z, unsigned
|
||||
{
|
||||
Bit16s prev_x, prev_y;
|
||||
|
||||
if (d.type == USB_DEV_TYPE_MOUSE) {
|
||||
if (d.type == USB_HID_TYPE_MOUSE) {
|
||||
// scale down the motion
|
||||
if ((delta_x < -1) || (delta_x > 1))
|
||||
delta_x /= 2;
|
||||
@ -1135,7 +1149,7 @@ void usb_hid_device_c::mouse_enq(int delta_x, int delta_y, int delta_z, unsigned
|
||||
}
|
||||
s.has_events = 1;
|
||||
}
|
||||
} else if (d.type == USB_DEV_TYPE_TABLET) {
|
||||
} else if (d.type == USB_HID_TYPE_TABLET) {
|
||||
prev_x = s.mouse_x;
|
||||
prev_y = s.mouse_y;
|
||||
if (absxy) {
|
||||
@ -1167,8 +1181,8 @@ int usb_hid_device_c::keyboard_poll(Bit8u *buf, int len, bool force)
|
||||
{
|
||||
int l = USB_RET_NAK;
|
||||
|
||||
if ((d.type == USB_DEV_TYPE_KEYPAD) ||
|
||||
(d.type == USB_DEV_TYPE_KEYBOARD)) {
|
||||
if ((d.type == USB_HID_TYPE_KEYPAD) ||
|
||||
(d.type == USB_HID_TYPE_KEYBOARD)) {
|
||||
if (s.has_events || force) {
|
||||
memcpy(buf, s.kbd_packet, len);
|
||||
l = 8;
|
||||
@ -1198,7 +1212,7 @@ bool usb_hid_device_c::gen_scancode(Bit32u key)
|
||||
|
||||
code = usbkbd_conv[key & ~BX_KEY_RELEASED].code;
|
||||
modkey = usbkbd_conv[key & ~BX_KEY_RELEASED].modkey;
|
||||
if (d.type == USB_DEV_TYPE_KEYPAD) {
|
||||
if (d.type == USB_HID_TYPE_KEYPAD) {
|
||||
if ((code < 0x53) || (code > 0x63)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
class usb_hid_device_c : public usb_device_c {
|
||||
public:
|
||||
usb_hid_device_c(usbdev_type type);
|
||||
usb_hid_device_c(const char *devname);
|
||||
virtual ~usb_hid_device_c(void);
|
||||
|
||||
virtual bool init();
|
||||
|
@ -57,7 +57,7 @@ class bx_usb_hub_locator_c : public usbdev_locator_c {
|
||||
public:
|
||||
bx_usb_hub_locator_c(void) : usbdev_locator_c("usb_hub") {}
|
||||
protected:
|
||||
usb_device_c *allocate(usbdev_type devtype) {
|
||||
usb_device_c *allocate(const char *devname) {
|
||||
return (new usb_hub_device_c());
|
||||
}
|
||||
} bx_usb_hub_match;
|
||||
@ -196,7 +196,6 @@ usb_hub_device_c::usb_hub_device_c()
|
||||
char pname[10];
|
||||
char label[32];
|
||||
|
||||
d.type = USB_DEV_TYPE_HUB;
|
||||
d.speed = d.minspeed = d.maxspeed = USB_SPEED_FULL;
|
||||
strcpy(d.devname, "Bochs USB HUB");
|
||||
d.dev_descriptor = bx_hub_dev_descriptor;
|
||||
@ -269,9 +268,11 @@ bool usb_hub_device_c::init()
|
||||
sprintf(label, "Port #%d Configuration", i+1);
|
||||
port = new bx_list_c(hub.config, pname, label);
|
||||
port->set_options(port->SERIES_ASK | port->USE_BOX_TITLE);
|
||||
device = new bx_param_enum_c(port, "device", "Device", "", usb_device_names, 0, 0);
|
||||
device = new bx_param_enum_c(port, "device", "Device", "",
|
||||
bx_usbdev_ctl.get_device_names(), 0, 0);
|
||||
device->set_handler(hub_param_handler);
|
||||
options = new bx_param_string_c(port, "options", "Options", "", "", BX_PATHNAME_LEN);
|
||||
options = new bx_param_string_c(port, "options", "Options", "", "",
|
||||
BX_PATHNAME_LEN);
|
||||
deplist = new bx_list_c(NULL);
|
||||
deplist->add(options);
|
||||
device->set_dependent_list(deplist, 1);
|
||||
@ -281,7 +282,7 @@ bool usb_hub_device_c::init()
|
||||
bx_list_c *usb = (bx_list_c*)SIM->get_param("ports.usb");
|
||||
usb->add(hub.config);
|
||||
}
|
||||
sprintf(hub.info_txt, "ports = %d", hub.n_ports);
|
||||
sprintf(hub.info_txt, "%d-port USB hub", hub.n_ports);
|
||||
d.connected = 1;
|
||||
return 1;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ private:
|
||||
bx_list_c *config;
|
||||
bx_list_c *state;
|
||||
char serial_number[16];
|
||||
char info_txt[16];
|
||||
char info_txt[18];
|
||||
struct {
|
||||
// our data
|
||||
usb_device_c *device; // device connected to this port
|
||||
|
@ -57,11 +57,14 @@ class bx_usb_msd_locator_c : public usbdev_locator_c {
|
||||
public:
|
||||
bx_usb_msd_locator_c(void) : usbdev_locator_c("usb_msd") {}
|
||||
protected:
|
||||
usb_device_c *allocate(usbdev_type devtype) {
|
||||
return (new usb_msd_device_c(devtype));
|
||||
usb_device_c *allocate(const char *devname) {
|
||||
return (new usb_msd_device_c(devname));
|
||||
}
|
||||
} bx_usb_msd_match;
|
||||
|
||||
#define USB_MSD_TYPE_DISK 0
|
||||
#define USB_MSD_TYPE_CDROM 1
|
||||
|
||||
enum USBMSDMode {
|
||||
USB_MSDM_CBW,
|
||||
USB_MSDM_DATAOUT,
|
||||
@ -333,26 +336,30 @@ void usb_msd_restore_handler(void *dev, bx_list_c *conf);
|
||||
|
||||
static Bit8u usb_cdrom_count = 0;
|
||||
|
||||
usb_msd_device_c::usb_msd_device_c(usbdev_type type)
|
||||
usb_msd_device_c::usb_msd_device_c(const char *devname)
|
||||
{
|
||||
char pname[10];
|
||||
char label[32];
|
||||
bx_param_string_c *path;
|
||||
bx_param_enum_c *status;
|
||||
|
||||
d.type = type;
|
||||
if (!strcmp(devname, "disk")) {
|
||||
d.type = USB_MSD_TYPE_DISK;
|
||||
} else {
|
||||
d.type = USB_MSD_TYPE_CDROM;
|
||||
}
|
||||
d.minspeed = USB_SPEED_FULL;
|
||||
d.maxspeed = USB_SPEED_SUPER;
|
||||
d.speed = d.minspeed;
|
||||
memset((void*)&s, 0, sizeof(s));
|
||||
if (d.type == USB_DEV_TYPE_DISK) {
|
||||
if (d.type == USB_MSD_TYPE_DISK) {
|
||||
strcpy(d.devname, "BOCHS USB HARDDRIVE");
|
||||
s.fname[0] = 0;
|
||||
s.image_mode = strdup("flat");
|
||||
s.journal[0] = 0;
|
||||
s.size = 0;
|
||||
s.sect_size = 512;
|
||||
} else if (d.type == USB_DEV_TYPE_CDROM) {
|
||||
} else if (d.type == USB_MSD_TYPE_CDROM) {
|
||||
strcpy(d.devname, "BOCHS USB CDROM");
|
||||
// config options
|
||||
bx_list_c *usb_rt = (bx_list_c*)SIM->get_param(BXPN_MENU_RUNTIME_USB);
|
||||
@ -412,7 +419,7 @@ bool usb_msd_device_c::set_option(const char *option)
|
||||
|
||||
if (!strncmp(option, "path:", 5)) {
|
||||
strcpy(filename, option+5);
|
||||
if (d.type == USB_DEV_TYPE_DISK) {
|
||||
if (d.type == USB_MSD_TYPE_DISK) {
|
||||
ptr1 = strtok(filename, ":");
|
||||
ptr2 = strtok(NULL, ":");
|
||||
if ((ptr2 == NULL) || (strlen(ptr1) < 2)) {
|
||||
@ -430,14 +437,14 @@ bool usb_msd_device_c::set_option(const char *option)
|
||||
}
|
||||
return 1;
|
||||
} else if (!strncmp(option, "journal:", 8)) {
|
||||
if (d.type == USB_DEV_TYPE_DISK) {
|
||||
if (d.type == USB_MSD_TYPE_DISK) {
|
||||
strcpy(s.journal, option+8);
|
||||
return 1;
|
||||
} else {
|
||||
BX_ERROR(("Option 'journal' is only valid for USB disks"));
|
||||
}
|
||||
} else if (!strncmp(option, "size:", 5)) {
|
||||
if ((d.type == USB_DEV_TYPE_DISK) && (!strcmp(s.image_mode, "vvfat"))) {
|
||||
if ((d.type == USB_MSD_TYPE_DISK) && (!strcmp(s.image_mode, "vvfat"))) {
|
||||
s.size = (int)strtol(option+5, &suffix, 10);
|
||||
if (!strcmp(suffix, "G")) {
|
||||
s.size <<= 10;
|
||||
@ -456,7 +463,7 @@ bool usb_msd_device_c::set_option(const char *option)
|
||||
BX_ERROR(("Option 'size' is only valid for USB VVFAT disks"));
|
||||
}
|
||||
} else if (!strncmp(option, "sect_size:", 10)) {
|
||||
if (d.type == USB_DEV_TYPE_DISK) {
|
||||
if (d.type == USB_MSD_TYPE_DISK) {
|
||||
s.sect_size = (unsigned)strtol(option+10, &suffix, 10);
|
||||
if (strlen(suffix) > 0) {
|
||||
BX_ERROR(("Option 'sect_size': ignoring extra data"));
|
||||
@ -475,7 +482,7 @@ bool usb_msd_device_c::set_option(const char *option)
|
||||
|
||||
bool usb_msd_device_c::init()
|
||||
{
|
||||
if (d.type == USB_DEV_TYPE_DISK) {
|
||||
if (d.type == USB_MSD_TYPE_DISK) {
|
||||
if (strlen(s.fname) > 0) {
|
||||
s.hdimage = DEV_hdimage_init_image(s.image_mode, 0, s.journal);
|
||||
if (!strcmp(s.image_mode, "vvfat")) {
|
||||
@ -499,7 +506,7 @@ bool usb_msd_device_c::init()
|
||||
BX_ERROR(("USB HD: disk image not specified"));
|
||||
return 0;
|
||||
}
|
||||
} else if (d.type == USB_DEV_TYPE_CDROM) {
|
||||
} else if (d.type == USB_MSD_TYPE_CDROM) {
|
||||
s.cdrom = DEV_hdimage_init_cdrom(s.fname);
|
||||
s.scsi_dev = new scsi_device_t(s.cdrom, 0, usb_msd_command_complete, (void*)this);
|
||||
if (set_inserted(1)) {
|
||||
@ -543,12 +550,12 @@ const char* usb_msd_device_c::get_info()
|
||||
void usb_msd_device_c::register_state_specific(bx_list_c *parent)
|
||||
{
|
||||
s.sr_list = new bx_list_c(parent, "s", "USB MSD Device State");
|
||||
if (d.type == USB_DEV_TYPE_CDROM) {
|
||||
if (d.type == USB_MSD_TYPE_CDROM) {
|
||||
bx_list_c *rt_config = new bx_list_c(s.sr_list, "rt_config");
|
||||
rt_config->add(s.config->get_by_name("path"));
|
||||
rt_config->add(s.config->get_by_name("status"));
|
||||
rt_config->set_restore_handler(this, usb_msd_restore_handler);
|
||||
} else if ((d.type == USB_DEV_TYPE_DISK) && (s.hdimage != NULL)) {
|
||||
} else if ((d.type == USB_MSD_TYPE_DISK) && (s.hdimage != NULL)) {
|
||||
s.hdimage->register_state(s.sr_list);
|
||||
}
|
||||
BXRS_DEC_PARAM_FIELD(s.sr_list, mode, s.mode);
|
||||
@ -964,7 +971,7 @@ bool usb_msd_device_c::get_locked()
|
||||
|
||||
void usb_msd_device_c::runtime_config(void)
|
||||
{
|
||||
if (d.type == USB_DEV_TYPE_CDROM) {
|
||||
if (d.type == USB_MSD_TYPE_CDROM) {
|
||||
if (s.status_changed) {
|
||||
set_inserted(0);
|
||||
if (SIM->get_param_enum("status", s.config)->get() == BX_INSERTED) {
|
||||
|
@ -32,7 +32,7 @@ class scsi_device_t;
|
||||
|
||||
class usb_msd_device_c : public usb_device_c {
|
||||
public:
|
||||
usb_msd_device_c(usbdev_type type);
|
||||
usb_msd_device_c(const char *devname);
|
||||
virtual ~usb_msd_device_c(void);
|
||||
|
||||
virtual bool init();
|
||||
|
@ -52,8 +52,8 @@ class bx_usb_printer_locator_c : public usbdev_locator_c {
|
||||
public:
|
||||
bx_usb_printer_locator_c(void) : usbdev_locator_c("usb_printer") {}
|
||||
protected:
|
||||
usb_device_c *allocate(usbdev_type devtype) {
|
||||
return (new usb_printer_device_c(devtype));
|
||||
usb_device_c *allocate(const char *devname) {
|
||||
return (new usb_printer_device_c());
|
||||
}
|
||||
} bx_usb_printer_match;
|
||||
|
||||
@ -135,13 +135,12 @@ static const Bit8u bx_device_id_string[] =
|
||||
|
||||
static Bit8u usb_printer_count = 0;
|
||||
|
||||
usb_printer_device_c::usb_printer_device_c(usbdev_type type)
|
||||
usb_printer_device_c::usb_printer_device_c()
|
||||
{
|
||||
char pname[12];
|
||||
char label[32];
|
||||
bx_param_string_c *fname;
|
||||
|
||||
d.type = type;
|
||||
d.speed = d.minspeed = d.maxspeed = USB_SPEED_FULL;
|
||||
memset((void*)&s, 0, sizeof(s));
|
||||
strcpy(d.devname, "USB Printer");
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
class usb_printer_device_c : public usb_device_c {
|
||||
public:
|
||||
usb_printer_device_c(usbdev_type type);
|
||||
usb_printer_device_c(void);
|
||||
virtual ~usb_printer_device_c(void);
|
||||
|
||||
virtual bool init();
|
||||
|
Loading…
x
Reference in New Issue
Block a user