static int xhci_ep_nuke_xfers(XHCIState *xhci, unsigned int slotid,

                               unsigned int epid, TRBCCode report)

{

    XHCISlot *slot;

    XHCIEPContext *epctx;

    int i, xferi, killed = 0;

    USBEndpoint *ep = NULL;

    assert(slotid >= 1 && slotid <= xhci->numslots);

    assert(epid >= 1 && epid <= 31);



    DPRINTF("xhci_ep_nuke_xfers(%d, %d)\n", slotid, epid);



    slot = &xhci->slots[slotid-1];



    if (!slot->eps[epid-1]) {

        return 0;

    }



    epctx = slot->eps[epid-1];



    xferi = epctx->next_xfer;

    for (i = 0; i < TD_QUEUE; i++) {

        killed += xhci_ep_nuke_one_xfer(&epctx->transfers[xferi], report);

        if (killed) {

            report = 0; /* Only report once */

        }

        epctx->transfers[xferi].packet.ep = NULL;

        xferi = (xferi + 1) % TD_QUEUE;

    }



    ep = xhci_epid_to_usbep(xhci, slotid, epid);

    if (ep) {

        usb_device_ep_stopped(ep->dev, ep);

    }

    return killed;

}

static int xhci_ep_nuke_xfers(XHCIState *xhci, unsigned int slotid,

                               unsigned int epid, TRBCCode report)

{

    XHCISlot *slot;

    XHCIEPContext *epctx;

    int i, xferi, killed = 0;

    USBEndpoint *ep = NULL;

    assert(slotid >= 1 && slotid <= xhci->numslots);

    assert(epid >= 1 && epid <= 31);



    DPRINTF("xhci_ep_nuke_xfers(%d, %d)\n", slotid, epid);



    slot = &xhci->slots[slotid-1];



    if (!slot->eps[epid-1]) {

        return 0;

    }



    epctx = slot->eps[epid-1];



    xferi = epctx->next_xfer;

    for (i = 0; i < TD_QUEUE; i++) {

        killed += xhci_ep_nuke_one_xfer(&epctx->transfers[xferi], report);

        if (killed) {

            report = 0; 

        }

        epctx->transfers[xferi].packet.ep = NULL;

        xferi = (xferi + 1) % TD_QUEUE;

    }



    ep = xhci_epid_to_usbep(xhci, slotid, epid);

    if (ep) {

        usb_device_ep_stopped(ep->dev, ep);

    }

    return killed;

}

static int FUNC_0(XHCIState *VAR_0, unsigned int VAR_1,

                               unsigned int VAR_2, TRBCCode VAR_3)

{

    XHCISlot *slot;

    XHCIEPContext *epctx;

    int VAR_4, VAR_5, VAR_6 = 0;

    USBEndpoint *ep = NULL;

    assert(VAR_1 >= 1 && VAR_1 <= VAR_0->numslots);

    assert(VAR_2 >= 1 && VAR_2 <= 31);



    DPRINTF("FUNC_0(%d, %d)\n", VAR_1, VAR_2);



    slot = &VAR_0->slots[VAR_1-1];



    if (!slot->eps[VAR_2-1]) {

        return 0;

    }



    epctx = slot->eps[VAR_2-1];



    VAR_5 = epctx->next_xfer;

    for (VAR_4 = 0; VAR_4 < TD_QUEUE; VAR_4++) {

        VAR_6 += xhci_ep_nuke_one_xfer(&epctx->transfers[VAR_5], VAR_3);

        if (VAR_6) {

            VAR_3 = 0; 

        }

        epctx->transfers[VAR_5].packet.ep = NULL;

        VAR_5 = (VAR_5 + 1) % TD_QUEUE;

    }



    ep = xhci_epid_to_usbep(VAR_0, VAR_1, VAR_2);

    if (ep) {

        usb_device_ep_stopped(ep->dev, ep);

    }

    return VAR_6;

}

static int FUNC_0(XHCIState *VAR_0, unsigned int VAR_1,
unsigned int VAR_2, TRBCCode VAR_3)
{ XHCISlot *slot; XHCIEPContext *epctx; int VAR_4, VAR_5, VAR_6 = 0; USBEndpoint *ep = NULL; assert(VAR_1 >= 1 && VAR_1 <= VAR_0->numslots); assert(VAR_2 >= 1 && VAR_2 <= 31); DPRINTF("FUNC_0(%d, %d)\n", VAR_1, VAR_2); slot = &VAR_0->slots[VAR_1-1]; if (!slot->eps[VAR_2-1]) { return 0; } epctx = slot->eps[VAR_2-1]; VAR_5 = epctx->next_xfer; for (VAR_4 = 0; VAR_4 < TD_QUEUE; VAR_4++) { VAR_6 += xhci_ep_nuke_one_xfer(&epctx->transfers[VAR_5], VAR_3); if (VAR_6) { VAR_3 = 0; } epctx->transfers[VAR_5].packet.ep = NULL; VAR_5 = (VAR_5 + 1) % TD_QUEUE; } ep = xhci_epid_to_usbep(VAR_0, VAR_1, VAR_2); if (ep) { usb_device_ep_stopped(ep->dev, ep); } return VAR_6; }