hcd-xhci.c (b55160c3d9b38c5d481ceccc30e397430f26fe92) hcd-xhci.c (8550a02d1239415342959f6a32d178bc05c557cc)
1/*
2 * USB xHCI controller emulation
3 *
4 * Copyright (c) 2011 Securiforest
5 * Date: 2011-05-11 ; Author: Hector Martin <hector@marcansoft.com>
6 * Based on usb-ohci.c, emulates Renesas NEC USB 3.0
7 *
8 * This library is free software; you can redistribute it and/or

--- 1504 unchanged lines hidden (view full) ---

1513 xfer->slotid);
1514 return -1;
1515 }
1516 dev = xhci->slots[xfer->slotid-1].uport->dev;
1517 ep = usb_ep_get(dev, dir, xfer->epid >> 1);
1518 }
1519
1520 xhci_xfer_create_sgl(xfer, dir == USB_TOKEN_IN); /* Also sets int_req */
1/*
2 * USB xHCI controller emulation
3 *
4 * Copyright (c) 2011 Securiforest
5 * Date: 2011-05-11 ; Author: Hector Martin <hector@marcansoft.com>
6 * Based on usb-ohci.c, emulates Renesas NEC USB 3.0
7 *
8 * This library is free software; you can redistribute it and/or

--- 1504 unchanged lines hidden (view full) ---

1513 xfer->slotid);
1514 return -1;
1515 }
1516 dev = xhci->slots[xfer->slotid-1].uport->dev;
1517 ep = usb_ep_get(dev, dir, xfer->epid >> 1);
1518 }
1519
1520 xhci_xfer_create_sgl(xfer, dir == USB_TOKEN_IN); /* Also sets int_req */
1521 usb_packet_setup(&xfer->packet, dir, ep, xfer->trbs[0].addr, false,
1522 xfer->int_req);
1521 usb_packet_setup(&xfer->packet, dir, ep, 0,
1522 xfer->trbs[0].addr, false, xfer->int_req);
1523 usb_packet_map(&xfer->packet, &xfer->sgl);
1524 DPRINTF("xhci: setup packet pid 0x%x addr %d ep %d\n",
1525 xfer->packet.pid, dev->addr, ep->nr);
1526 return 0;
1527}
1528
1529static int xhci_complete_packet(XHCITransfer *xfer)
1530{

--- 441 unchanged lines hidden (view full) ---

1972 slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT;
1973 } else {
1974 USBPacket p;
1975 slot->devaddr = xhci->devaddr++;
1976 slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slot->devaddr;
1977 DPRINTF("xhci: device address is %d\n", slot->devaddr);
1978 usb_device_reset(dev);
1979 usb_packet_setup(&p, USB_TOKEN_OUT,
1523 usb_packet_map(&xfer->packet, &xfer->sgl);
1524 DPRINTF("xhci: setup packet pid 0x%x addr %d ep %d\n",
1525 xfer->packet.pid, dev->addr, ep->nr);
1526 return 0;
1527}
1528
1529static int xhci_complete_packet(XHCITransfer *xfer)
1530{

--- 441 unchanged lines hidden (view full) ---

1972 slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT;
1973 } else {
1974 USBPacket p;
1975 slot->devaddr = xhci->devaddr++;
1976 slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slot->devaddr;
1977 DPRINTF("xhci: device address is %d\n", slot->devaddr);
1978 usb_device_reset(dev);
1979 usb_packet_setup(&p, USB_TOKEN_OUT,
1980 usb_ep_get(dev, USB_TOKEN_OUT, 0),
1980 usb_ep_get(dev, USB_TOKEN_OUT, 0), 0,
1981 0, false, false);
1982 usb_device_handle_control(dev, &p,
1983 DeviceOutRequest | USB_REQ_SET_ADDRESS,
1984 slot->devaddr, 0, 0, NULL);
1985 assert(p.status != USB_RET_ASYNC);
1986 }
1987
1988 res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx);

--- 1039 unchanged lines hidden (view full) ---

3028 }
3029 if (ep->pid == USB_TOKEN_IN) {
3030 return ep->nr * 2 + 1;
3031 } else {
3032 return ep->nr * 2;
3033 }
3034}
3035
1981 0, false, false);
1982 usb_device_handle_control(dev, &p,
1983 DeviceOutRequest | USB_REQ_SET_ADDRESS,
1984 slot->devaddr, 0, 0, NULL);
1985 assert(p.status != USB_RET_ASYNC);
1986 }
1987
1988 res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx);

--- 1039 unchanged lines hidden (view full) ---

3028 }
3029 if (ep->pid == USB_TOKEN_IN) {
3030 return ep->nr * 2 + 1;
3031 } else {
3032 return ep->nr * 2;
3033 }
3034}
3035
3036static void xhci_wakeup_endpoint(USBBus *bus, USBEndpoint *ep)
3036static void xhci_wakeup_endpoint(USBBus *bus, USBEndpoint *ep,
3037 unsigned int stream)
3037{
3038 XHCIState *xhci = container_of(bus, XHCIState, bus);
3039 int slotid;
3040
3041 DPRINTF("%s\n", __func__);
3042 slotid = xhci_find_slotid(xhci, ep->dev);
3043 if (slotid == 0 || !xhci->slots[slotid-1].enabled) {
3044 DPRINTF("%s: oops, no slot for dev %d\n", __func__, ep->dev->addr);

--- 172 unchanged lines hidden ---
3038{
3039 XHCIState *xhci = container_of(bus, XHCIState, bus);
3040 int slotid;
3041
3042 DPRINTF("%s\n", __func__);
3043 slotid = xhci_find_slotid(xhci, ep->dev);
3044 if (slotid == 0 || !xhci->slots[slotid-1].enabled) {
3045 DPRINTF("%s: oops, no slot for dev %d\n", __func__, ep->dev->addr);

--- 172 unchanged lines hidden ---