~ubuntu-branches/ubuntu/natty/qemu-kvm/natty

« back to all changes in this revision

Viewing changes to hw/usb-uhci.c

  • Committer: Dustin Kirkland
  • Author(s): Serge Hallyn, Serge Hallyn, Dustin Kirkland, Steve Langasek
  • Date: 2011-02-14 13:50:16 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: kirkland@ubuntu.com-20110214135016-2kpdvznxkr5umnkb
Tags: 0.14.0~rc1+noroms-0ubuntu1
[ Serge Hallyn ]
* Merge qemu-kvm 0.14.0-rc1
* removed all rom's
* removed tests/pi_10.com as it's binary data
* removed 697197-fix-vnc-password-semantics.patch in favor of upstream fix
* removed caps-lock-key-up-event.patch - upstream commit
  9a121a2fbf88dd1bc869b1ac2449dc12c27cccfa is supposed to fix it
  - bdrung to verify
* removed 1000-undo-earlier-static.patch
  - re-add if build fails - but we no longer do static build
* removed 2000-vmmouse-adapt-to-mouse-handler-changes.patch, now upstream
* removed arm patches - qemu-kvm now only offers x86 and ppc emulation
  - qemu-user provides armel
* kvmtrace_format is now shipped with different tree.

[ Dustin Kirkland ]
* Re-roll tarball, adding ~rc1 to version, so that the official GA release
  will supercede these rc's
* debian/control: bump standards versions, remove redundant depends on
  adduser, update section to misc
* debian/rules: drop qemu-system-ppc64 from the build, as this is in
  qemu-linaro now, LP: #717690
* debian/copyright: embed the BSD license, per lintian

[ Steve Langasek ]
* debian/rules: drop the binfmt-misc handling; we're not building any
  static user binaries from this source, so this is just noise.
* debian/rules: $INSTALL_PROGRAM is never set, so modifying it is
  pointless.  Delete this as well.
* build qemu-kvm package on all archs; this is the authoritative package
  for x86 system emulators, so we only have to deal with the bios
  dependencies in one place.
* don't run 'make install' in kvm/libkvm directory, this is a no-op anyway.
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
#define TD_CTRL_NAK     (1 << 19)
58
58
#define TD_CTRL_TIMEOUT (1 << 18)
59
59
 
 
60
#define UHCI_PORT_SUSPEND (1 << 12)
60
61
#define UHCI_PORT_RESET (1 << 9)
61
62
#define UHCI_PORT_LSDA  (1 << 8)
 
63
#define UHCI_PORT_RD    (1 << 6)
62
64
#define UHCI_PORT_ENC   (1 << 3)
63
65
#define UHCI_PORT_EN    (1 << 2)
64
66
#define UHCI_PORT_CSC   (1 << 1)
65
67
#define UHCI_PORT_CCS   (1 << 0)
66
68
 
 
69
#define UHCI_PORT_READ_ONLY    (0x1bb)
 
70
#define UHCI_PORT_WRITE_CLEAR  (UHCI_PORT_CSC | UHCI_PORT_ENC)
 
71
 
67
72
#define FRAME_TIMER_FREQ 1000
68
73
 
69
74
#define FRAME_MAX_LOOPS  100
307
312
    return match;
308
313
}
309
314
 
310
 
static void uhci_attach(USBPort *port1, USBDevice *dev);
311
 
 
312
315
static void uhci_update_irq(UHCIState *s)
313
316
{
314
317
    int level;
348
351
    for(i = 0; i < NB_PORTS; i++) {
349
352
        port = &s->ports[i];
350
353
        port->ctrl = 0x0080;
351
 
        if (port->port.dev)
352
 
            uhci_attach(&port->port, port->port.dev);
 
354
        if (port->port.dev) {
 
355
            usb_attach(&port->port, port->port.dev);
 
356
        }
353
357
    }
354
358
 
355
359
    uhci_async_cancel_all(s);
498
502
                    usb_send_msg(dev, USB_MSG_RESET);
499
503
                }
500
504
            }
501
 
            port->ctrl = (port->ctrl & 0x01fb) | (val & ~0x01fb);
 
505
            port->ctrl &= UHCI_PORT_READ_ONLY;
 
506
            port->ctrl |= (val & ~UHCI_PORT_READ_ONLY);
502
507
            /* some bits are reset when a '1' is written to them */
503
 
            port->ctrl &= ~(val & 0x000a);
 
508
            port->ctrl &= ~(val & UHCI_PORT_WRITE_CLEAR);
504
509
        }
505
510
        break;
506
511
    }
593
598
    }
594
599
}
595
600
 
596
 
static void uhci_attach(USBPort *port1, USBDevice *dev)
 
601
static void uhci_attach(USBPort *port1)
597
602
{
598
603
    UHCIState *s = port1->opaque;
599
604
    UHCIPort *port = &s->ports[port1->index];
600
605
 
601
 
    if (dev) {
602
 
        if (port->port.dev) {
603
 
            usb_attach(port1, NULL);
604
 
        }
605
 
        /* set connect status */
606
 
        port->ctrl |= UHCI_PORT_CCS | UHCI_PORT_CSC;
607
 
 
608
 
        /* update speed */
609
 
        if (dev->speed == USB_SPEED_LOW)
610
 
            port->ctrl |= UHCI_PORT_LSDA;
611
 
        else
612
 
            port->ctrl &= ~UHCI_PORT_LSDA;
613
 
 
614
 
        uhci_resume(s);
615
 
 
616
 
        port->port.dev = dev;
617
 
        /* send the attach message */
618
 
        usb_send_msg(dev, USB_MSG_ATTACH);
 
606
    /* set connect status */
 
607
    port->ctrl |= UHCI_PORT_CCS | UHCI_PORT_CSC;
 
608
 
 
609
    /* update speed */
 
610
    if (port->port.dev->speed == USB_SPEED_LOW) {
 
611
        port->ctrl |= UHCI_PORT_LSDA;
619
612
    } else {
620
 
        /* set connect status */
621
 
        if (port->ctrl & UHCI_PORT_CCS) {
622
 
            port->ctrl &= ~UHCI_PORT_CCS;
623
 
            port->ctrl |= UHCI_PORT_CSC;
624
 
        }
625
 
        /* disable port */
626
 
        if (port->ctrl & UHCI_PORT_EN) {
627
 
            port->ctrl &= ~UHCI_PORT_EN;
628
 
            port->ctrl |= UHCI_PORT_ENC;
629
 
        }
630
 
 
 
613
        port->ctrl &= ~UHCI_PORT_LSDA;
 
614
    }
 
615
 
 
616
    uhci_resume(s);
 
617
}
 
618
 
 
619
static void uhci_detach(USBPort *port1)
 
620
{
 
621
    UHCIState *s = port1->opaque;
 
622
    UHCIPort *port = &s->ports[port1->index];
 
623
 
 
624
    /* set connect status */
 
625
    if (port->ctrl & UHCI_PORT_CCS) {
 
626
        port->ctrl &= ~UHCI_PORT_CCS;
 
627
        port->ctrl |= UHCI_PORT_CSC;
 
628
    }
 
629
    /* disable port */
 
630
    if (port->ctrl & UHCI_PORT_EN) {
 
631
        port->ctrl &= ~UHCI_PORT_EN;
 
632
        port->ctrl |= UHCI_PORT_ENC;
 
633
    }
 
634
 
 
635
    uhci_resume(s);
 
636
}
 
637
 
 
638
static void uhci_wakeup(USBDevice *dev)
 
639
{
 
640
    USBBus *bus = usb_bus_from_device(dev);
 
641
    UHCIState *s = container_of(bus, UHCIState, bus);
 
642
    UHCIPort *port = s->ports + dev->port->index;
 
643
 
 
644
    if (port->ctrl & UHCI_PORT_SUSPEND && !(port->ctrl & UHCI_PORT_RD)) {
 
645
        port->ctrl |= UHCI_PORT_RD;
631
646
        uhci_resume(s);
632
 
 
633
 
        dev = port->port.dev;
634
 
        if (dev) {
635
 
            /* send the detach message */
636
 
            usb_send_msg(dev, USB_MSG_DETACH);
637
 
        }
638
 
        port->port.dev = NULL;
639
647
    }
640
648
}
641
649
 
1101
1109
    register_ioport_read(addr, 32, 1, uhci_ioport_readb, s);
1102
1110
}
1103
1111
 
 
1112
static USBPortOps uhci_port_ops = {
 
1113
    .attach = uhci_attach,
 
1114
    .detach = uhci_detach,
 
1115
    .wakeup = uhci_wakeup,
 
1116
};
 
1117
 
1104
1118
static int usb_uhci_common_initfn(UHCIState *s)
1105
1119
{
1106
1120
    uint8_t *pci_conf = s->dev.config;
1115
1129
 
1116
1130
    usb_bus_new(&s->bus, &s->dev.qdev);
1117
1131
    for(i = 0; i < NB_PORTS; i++) {
1118
 
        usb_register_port(&s->bus, &s->ports[i].port, s, i, uhci_attach);
 
1132
        usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,
 
1133
                          USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
 
1134
        usb_port_location(&s->ports[i].port, NULL, i+1);
1119
1135
    }
1120
1136
    s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s);
1121
1137
    s->expire_time = qemu_get_clock(vm_clock) +