~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to hw/usb/hcd-ehci.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
446
446
{
447
447
    int i;
448
448
 
449
 
    if (!ehci->dma) {
 
449
    if (!ehci->as) {
450
450
        ehci_raise_irq(ehci, USBSTS_HSE);
451
451
        ehci->usbcmd &= ~USBCMD_RUNSTOP;
452
452
        trace_usb_ehci_dma_error();
454
454
    }
455
455
 
456
456
    for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
457
 
        dma_memory_read(ehci->dma, addr, buf, sizeof(*buf));
 
457
        dma_memory_read(ehci->as, addr, buf, sizeof(*buf));
458
458
        *buf = le32_to_cpu(*buf);
459
459
    }
460
460
 
467
467
{
468
468
    int i;
469
469
 
470
 
    if (!ehci->dma) {
 
470
    if (!ehci->as) {
471
471
        ehci_raise_irq(ehci, USBSTS_HSE);
472
472
        ehci->usbcmd &= ~USBCMD_RUNSTOP;
473
473
        trace_usb_ehci_dma_error();
476
476
 
477
477
    for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
478
478
        uint32_t tmp = cpu_to_le32(*buf);
479
 
        dma_memory_write(ehci->dma, addr, &tmp, sizeof(tmp));
 
479
        dma_memory_write(ehci->as, addr, &tmp, sizeof(tmp));
480
480
    }
481
481
 
482
482
    return num;
995
995
    uint32_t val;
996
996
 
997
997
    val = s->portsc[addr >> 2];
998
 
    trace_usb_ehci_portsc_read(addr + PORTSC_BEGIN, addr >> 2, val);
 
998
    trace_usb_ehci_portsc_read(addr + s->portscbase, addr >> 2, val);
999
999
    return val;
1000
1000
}
1001
1001
 
1036
1036
    uint32_t old = *portsc;
1037
1037
    USBDevice *dev = s->ports[port].dev;
1038
1038
 
1039
 
    trace_usb_ehci_portsc_write(addr + PORTSC_BEGIN, addr >> 2, val);
 
1039
    trace_usb_ehci_portsc_write(addr + s->portscbase, addr >> 2, val);
1040
1040
 
1041
1041
    /* Clear rwc bits */
1042
1042
    *portsc &= ~(val & PORTSC_RWC_MASK);
1069
1069
 
1070
1070
    *portsc &= ~PORTSC_RO_MASK;
1071
1071
    *portsc |= val;
1072
 
    trace_usb_ehci_portsc_change(addr + PORTSC_BEGIN, addr >> 2, *portsc, old);
 
1072
    trace_usb_ehci_portsc_change(addr + s->portscbase, addr >> 2, *portsc, old);
1073
1073
}
1074
1074
 
1075
1075
static void ehci_opreg_write(void *ptr, hwaddr addr,
1245
1245
    cpage  = get_field(p->qtd.token, QTD_TOKEN_CPAGE);
1246
1246
    bytes  = get_field(p->qtd.token, QTD_TOKEN_TBYTES);
1247
1247
    offset = p->qtd.bufptr[0] & ~QTD_BUFPTR_MASK;
1248
 
    qemu_sglist_init(&p->sgl, 5, p->queue->ehci->dma);
 
1248
    qemu_sglist_init(&p->sgl, p->queue->ehci->device, 5, p->queue->ehci->as);
1249
1249
 
1250
1250
    while (bytes > 0) {
1251
1251
        if (cpage > 4) {
1355
1355
    default:
1356
1356
        /* should not be triggerable */
1357
1357
        fprintf(stderr, "USB invalid response %d\n", p->packet.status);
1358
 
        assert(0);
 
1358
        g_assert_not_reached();
1359
1359
        break;
1360
1360
    }
1361
1361
 
1484
1484
                return -1;
1485
1485
            }
1486
1486
 
1487
 
            qemu_sglist_init(&ehci->isgl, 2, ehci->dma);
 
1487
            qemu_sglist_init(&ehci->isgl, ehci->device, 2, ehci->as);
1488
1488
            if (off + len > 4096) {
1489
1489
                /* transfer crosses page border */
1490
1490
                uint32_t len2 = off + len - 4096;
2140
2140
        default:
2141
2141
            fprintf(stderr, "Bad state!\n");
2142
2142
            again = -1;
2143
 
            assert(0);
 
2143
            g_assert_not_reached();
2144
2144
            break;
2145
2145
        }
2146
2146
 
2204
2204
        /* this should only be due to a developer mistake */
2205
2205
        fprintf(stderr, "ehci: Bad asynchronous state %d. "
2206
2206
                "Resetting to active\n", ehci->astate);
2207
 
        assert(0);
 
2207
        g_assert_not_reached();
2208
2208
    }
2209
2209
}
2210
2210
 
2254
2254
        /* this should only be due to a developer mistake */
2255
2255
        fprintf(stderr, "ehci: Bad periodic state %d. "
2256
2256
                "Resetting to active\n", ehci->pstate);
2257
 
        assert(0);
 
2257
        g_assert_not_reached();
2258
2258
    }
2259
2259
}
2260
2260
 
2508
2508
    }
2509
2509
};
2510
2510
 
2511
 
void usb_ehci_initfn(EHCIState *s, DeviceState *dev)
 
2511
void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
2512
2512
{
2513
2513
    int i;
2514
2514
 
 
2515
    if (s->portnr > NB_PORTS) {
 
2516
        error_setg(errp, "Too many ports! Max. port number is %d.",
 
2517
                   NB_PORTS);
 
2518
        return;
 
2519
    }
 
2520
 
 
2521
    usb_bus_new(&s->bus, &ehci_bus_ops, dev);
 
2522
    for (i = 0; i < s->portnr; i++) {
 
2523
        usb_register_port(&s->bus, &s->ports[i], s, i, &ehci_port_ops,
 
2524
                          USB_SPEED_MASK_HIGH);
 
2525
        s->ports[i].dev = 0;
 
2526
    }
 
2527
 
 
2528
    s->frame_timer = qemu_new_timer_ns(vm_clock, ehci_frame_timer, s);
 
2529
    s->async_bh = qemu_bh_new(ehci_frame_timer, s);
 
2530
    s->device = dev;
 
2531
 
 
2532
    qemu_register_reset(ehci_reset, s);
 
2533
    qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s);
 
2534
}
 
2535
 
 
2536
void usb_ehci_init(EHCIState *s, DeviceState *dev)
 
2537
{
2515
2538
    /* 2.2 host controller interface version */
2516
2539
    s->caps[0x00] = (uint8_t)(s->opregbase - s->capsbase);
2517
2540
    s->caps[0x01] = 0x00;
2518
2541
    s->caps[0x02] = 0x00;
2519
2542
    s->caps[0x03] = 0x01;        /* HC version */
2520
 
    s->caps[0x04] = NB_PORTS;    /* Number of downstream ports */
 
2543
    s->caps[0x04] = s->portnr;   /* Number of downstream ports */
2521
2544
    s->caps[0x05] = 0x00;        /* No companion ports at present */
2522
2545
    s->caps[0x06] = 0x00;
2523
2546
    s->caps[0x07] = 0x00;
2525
2548
    s->caps[0x0a] = 0x00;
2526
2549
    s->caps[0x0b] = 0x00;
2527
2550
 
2528
 
    usb_bus_new(&s->bus, &ehci_bus_ops, dev);
2529
 
    for(i = 0; i < NB_PORTS; i++) {
2530
 
        usb_register_port(&s->bus, &s->ports[i], s, i, &ehci_port_ops,
2531
 
                          USB_SPEED_MASK_HIGH);
2532
 
        s->ports[i].dev = 0;
2533
 
    }
2534
 
 
2535
 
    s->frame_timer = qemu_new_timer_ns(vm_clock, ehci_frame_timer, s);
2536
 
    s->async_bh = qemu_bh_new(ehci_frame_timer, s);
2537
2551
    QTAILQ_INIT(&s->aqueues);
2538
2552
    QTAILQ_INIT(&s->pqueues);
2539
2553
    usb_packet_init(&s->ipacket);
2540
2554
 
2541
 
    qemu_register_reset(ehci_reset, s);
2542
 
    qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s);
2543
 
 
2544
 
    memory_region_init(&s->mem, "ehci", MMIO_SIZE);
2545
 
    memory_region_init_io(&s->mem_caps, &ehci_mmio_caps_ops, s,
 
2555
    memory_region_init(&s->mem, OBJECT(dev), "ehci", MMIO_SIZE);
 
2556
    memory_region_init_io(&s->mem_caps, OBJECT(dev), &ehci_mmio_caps_ops, s,
2546
2557
                          "capabilities", CAPA_SIZE);
2547
 
    memory_region_init_io(&s->mem_opreg, &ehci_mmio_opreg_ops, s,
2548
 
                          "operational", PORTSC_BEGIN);
2549
 
    memory_region_init_io(&s->mem_ports, &ehci_mmio_port_ops, s,
2550
 
                          "ports", PORTSC_END - PORTSC_BEGIN);
 
2558
    memory_region_init_io(&s->mem_opreg, OBJECT(dev), &ehci_mmio_opreg_ops, s,
 
2559
                          "operational", s->portscbase);
 
2560
    memory_region_init_io(&s->mem_ports, OBJECT(dev), &ehci_mmio_port_ops, s,
 
2561
                          "ports", 4 * s->portnr);
2551
2562
 
2552
2563
    memory_region_add_subregion(&s->mem, s->capsbase, &s->mem_caps);
2553
2564
    memory_region_add_subregion(&s->mem, s->opregbase, &s->mem_opreg);
2554
 
    memory_region_add_subregion(&s->mem, s->opregbase + PORTSC_BEGIN,
 
2565
    memory_region_add_subregion(&s->mem, s->opregbase + s->portscbase,
2555
2566
                                &s->mem_ports);
2556
2567
}
2557
2568