diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2005-11-06 16:13:29 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2005-11-06 16:13:29 +0000 |
commit | a594cfbf3e1a38bc6f3908d7d0903d41e8ea9da8 (patch) | |
tree | 08a6cbb83a11db3d8c675b95cfe427dcd981ce81 /hw | |
parent | 8738a8d079b661a612e89612844dc270ef5f0924 (diff) |
USB user interface
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1603 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r-- | hw/pc.c | 27 | ||||
-rw-r--r-- | hw/usb-uhci.c | 19 | ||||
-rw-r--r-- | hw/usb.c | 15 | ||||
-rw-r--r-- | hw/usb.h | 18 |
4 files changed, 35 insertions, 44 deletions
@@ -42,6 +42,7 @@ static fdctrl_t *floppy_controller; static RTCState *rtc_state; static PITState *pit; static IOAPICState *ioapic; +static USBPort *usb_root_ports[2]; static void ioport80_write(void *opaque, uint32_t addr, uint32_t data) { @@ -625,32 +626,8 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, cmos_init(ram_size, boot_device, bs_table); if (pci_enabled && usb_enabled) { - USBPort *usb_root_ports[2]; - USBDevice *usb_dev; usb_uhci_init(pci_bus, usb_root_ports); -#if 0 - { - USBPort *usb_hub1_ports[4]; - USBPort *usb_hub2_ports[2]; - /* test: we simulate a USB hub */ - usb_dev = usb_hub_init(usb_hub1_ports, 4); - usb_attach(usb_root_ports[0], usb_dev); - - /* test: we simulate a USB hub */ - usb_dev = usb_hub_init(usb_hub2_ports, 2); - usb_attach(usb_hub1_ports[0], usb_dev); - } -#endif -#if 0 - /* USB mouse */ - usb_dev = usb_mouse_init(); - usb_attach(usb_root_ports[0], usb_dev); -#endif -#if 1 - /* simulated hub with the host USB devices connected to it */ - usb_dev = usb_host_hub_init(); - usb_attach(usb_root_ports[0], usb_dev); -#endif + usb_attach(usb_root_ports[0], vm_usb_hub); } /* must be done after all PCI devices are instanciated */ diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index 4dd0c63815..0f0c185aae 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -63,7 +63,6 @@ typedef struct UHCIPort { USBPort port; uint16_t ctrl; - USBDevice *dev; /* connected device */ } UHCIPort; typedef struct UHCIState { @@ -128,8 +127,8 @@ static void uhci_reset(UHCIState *s) for(i = 0; i < NB_PORTS; i++) { port = &s->ports[i]; port->ctrl = 0x0080; - if (port->dev) - uhci_attach(&port->port, port->dev); + if (port->port.dev) + uhci_attach(&port->port, port->port.dev); } } @@ -183,7 +182,7 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val) /* send reset on the USB bus */ for(i = 0; i < NB_PORTS; i++) { port = &s->ports[i]; - dev = port->dev; + dev = port->port.dev; if (dev) { dev->handle_packet(dev, USB_MSG_RESET, 0, 0, NULL, 0); @@ -224,7 +223,7 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val) if (n >= NB_PORTS) return; port = &s->ports[n]; - dev = port->dev; + dev = port->port.dev; if (dev) { /* port reset */ if ( (val & UHCI_PORT_RESET) && @@ -320,7 +319,7 @@ static void uhci_attach(USBPort *port1, USBDevice *dev) UHCIPort *port = &s->ports[port1->index]; if (dev) { - if (port->dev) { + if (port->port.dev) { usb_attach(port1, NULL); } /* set connect status */ @@ -332,7 +331,7 @@ static void uhci_attach(USBPort *port1, USBDevice *dev) port->ctrl |= UHCI_PORT_LSDA; else port->ctrl &= ~UHCI_PORT_LSDA; - port->dev = dev; + port->port.dev = dev; /* send the attach message */ dev->handle_packet(dev, USB_MSG_ATTACH, 0, 0, NULL, 0); @@ -346,13 +345,13 @@ static void uhci_attach(USBPort *port1, USBDevice *dev) port->ctrl &= ~UHCI_PORT_EN; port->ctrl |= UHCI_PORT_ENC; } - dev = port->dev; + dev = port->port.dev; if (dev) { /* send the detach message */ dev->handle_packet(dev, USB_MSG_DETACH, 0, 0, NULL, 0); } - port->dev = NULL; + port->port.dev = NULL; } } @@ -386,7 +385,7 @@ static int uhci_broadcast_packet(UHCIState *s, uint8_t pid, #endif for(i = 0; i < NB_PORTS; i++) { port = &s->ports[i]; - dev = port->dev; + dev = port->port.dev; if (dev && (port->ctrl & UHCI_PORT_EN)) { ret = dev->handle_packet(dev, pid, devaddr, devep, @@ -201,7 +201,6 @@ int set_usb_string(uint8_t *buf, const char *str) typedef struct USBHubPort { USBPort port; - USBDevice *dev; uint16_t wPortStatus; uint16_t wPortChange; } USBHubPort; @@ -342,7 +341,7 @@ static void usb_hub_attach(USBPort *port1, USBDevice *dev) USBHubPort *port = &s->ports[port1->index]; if (dev) { - if (port->dev) + if (port->port.dev) usb_attach(port1, NULL); port->wPortStatus |= PORT_STAT_CONNECTION; @@ -351,9 +350,9 @@ static void usb_hub_attach(USBPort *port1, USBDevice *dev) port->wPortStatus |= PORT_STAT_LOW_SPEED; else port->wPortStatus &= ~PORT_STAT_LOW_SPEED; - port->dev = dev; + port->port.dev = dev; } else { - dev = port->dev; + dev = port->port.dev; if (dev) { port->wPortStatus &= ~PORT_STAT_CONNECTION; port->wPortChange |= PORT_STAT_C_CONNECTION; @@ -361,7 +360,7 @@ static void usb_hub_attach(USBPort *port1, USBDevice *dev) port->wPortStatus &= ~PORT_STAT_ENABLE; port->wPortChange |= PORT_STAT_C_ENABLE; } - port->dev = NULL; + port->port.dev = NULL; } } } @@ -498,7 +497,7 @@ static int usb_hub_handle_control(USBDevice *dev, int request, int value, if (n >= s->nb_ports) goto fail; port = &s->ports[n]; - dev = port->dev; + dev = port->port.dev; switch(value) { case PORT_SUSPEND: port->wPortStatus |= PORT_STAT_SUSPEND; @@ -529,7 +528,7 @@ static int usb_hub_handle_control(USBDevice *dev, int request, int value, if (n >= s->nb_ports) goto fail; port = &s->ports[n]; - dev = port->dev; + dev = port->port.dev; switch(value) { case PORT_ENABLE: port->wPortStatus &= ~PORT_STAT_ENABLE; @@ -624,7 +623,7 @@ static int usb_hub_broadcast_packet(USBHubState *s, int pid, for(i = 0; i < s->nb_ports; i++) { port = &s->ports[i]; - dev = port->dev; + dev = port->port.dev; if (dev && (port->wPortStatus & PORT_STAT_ENABLE)) { ret = dev->handle_packet(dev, pid, devaddr, devep, @@ -47,6 +47,20 @@ //#define USB_STATE_CONFIGURED 5 #define USB_STATE_SUSPENDED 6 +#define USB_CLASS_AUDIO 1 +#define USB_CLASS_COMM 2 +#define USB_CLASS_HID 3 +#define USB_CLASS_PHYSICAL 5 +#define USB_CLASS_STILL_IMAGE 6 +#define USB_CLASS_PRINTER 7 +#define USB_CLASS_MASS_STORAGE 8 +#define USB_CLASS_HUB 9 +#define USB_CLASS_CDC_DATA 0x0a +#define USB_CLASS_CSCID 0x0b +#define USB_CLASS_CONTENT_SEC 0x0d +#define USB_CLASS_APP_SPEC 0xfe +#define USB_CLASS_VENDOR_SPEC 0xff + #define USB_DIR_OUT 0 #define USB_DIR_IN 0x80 @@ -125,6 +139,7 @@ struct USBDevice { /* USB port on which a device can be connected */ struct USBPort { + USBDevice *dev; void (*attach)(USBPort *port, USBDevice *dev); void *opaque; int index; /* internal port index, may be used with the opaque */ @@ -143,7 +158,8 @@ USBDevice *usb_hub_init(USBPort **usb_ports, int nb_ports); void usb_uhci_init(PCIBus *bus, USBPort **usb_ports); /* usb-linux.c */ -USBDevice *usb_host_hub_init(void); +USBDevice *usb_host_device_open(const char *devname); +void usb_host_info(void); /* usb-hid.c */ USBDevice *usb_mouse_init(void); |