static int ehci_fill_queue(EHCIPacket *p)

{

    USBEndpoint *ep = p->packet.ep;

    EHCIQueue *q = p->queue;

    EHCIqtd qtd = p->qtd;

    uint32_t qtdaddr;



    for (;;) {

        if (NLPTR_TBIT(qtd.next) != 0) {



        qtdaddr = qtd.next;

        /*

         * Detect circular td lists, Windows creates these, counting on the

         * active bit going low after execution to make the queue stop.

         */

        QTAILQ_FOREACH(p, &q->packets, next) {

            if (p->qtdaddr == qtdaddr) {

                goto leave;



        if (get_dwords(q->ehci, NLPTR_GET(qtdaddr),

                       (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2) < 0) {

            return -1;


        ehci_trace_qtd(q, NLPTR_GET(qtdaddr), &qtd);

        if (!(qtd.token & QTD_TOKEN_ACTIVE)) {







        p = ehci_alloc_packet(q);

        p->qtdaddr = qtdaddr;

        p->qtd = qtd;

        if (ehci_execute(p, "queue") == -1) {

            return -1;


        assert(p->packet.status == USB_RET_ASYNC);

        p->async = EHCI_ASYNC_INFLIGHT;


leave:

    usb_device_flush_ep_queue(ep->dev, ep);

    return 1;

static int ehci_fill_queue(EHCIPacket *p)

{

    USBEndpoint *ep = p->packet.ep;

    EHCIQueue *q = p->queue;

    EHCIqtd qtd = p->qtd;

    uint32_t qtdaddr;



    for (;;) {

        if (NLPTR_TBIT(qtd.next) != 0) {



        qtdaddr = qtd.next;

        







        QTAILQ_FOREACH(p, &q->packets, next) {

            if (p->qtdaddr == qtdaddr) {

                goto leave;



        if (get_dwords(q->ehci, NLPTR_GET(qtdaddr),

                       (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2) < 0) {

            return -1;


        ehci_trace_qtd(q, NLPTR_GET(qtdaddr), &qtd);

        if (!(qtd.token & QTD_TOKEN_ACTIVE)) {







        p = ehci_alloc_packet(q);

        p->qtdaddr = qtdaddr;

        p->qtd = qtd;

        if (ehci_execute(p, "queue") == -1) {

            return -1;


        assert(p->packet.status == USB_RET_ASYNC);

        p->async = EHCI_ASYNC_INFLIGHT;


leave:

    usb_device_flush_ep_queue(ep->dev, ep);

    return 1;

static int FUNC_0(EHCIPacket *VAR_0)

{

    USBEndpoint *ep = VAR_0->packet.ep;

    EHCIQueue *q = VAR_0->queue;

    EHCIqtd qtd = VAR_0->qtd;

    uint32_t qtdaddr;



    for (;;) {

        if (NLPTR_TBIT(qtd.next) != 0) {



        qtdaddr = qtd.next;

        







        QTAILQ_FOREACH(VAR_0, &q->packets, next) {

            if (VAR_0->qtdaddr == qtdaddr) {

                goto leave;



        if (get_dwords(q->ehci, NLPTR_GET(qtdaddr),

                       (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2) < 0) {

            return -1;


        ehci_trace_qtd(q, NLPTR_GET(qtdaddr), &qtd);

        if (!(qtd.token & QTD_TOKEN_ACTIVE)) {







        VAR_0 = ehci_alloc_packet(q);

        VAR_0->qtdaddr = qtdaddr;

        VAR_0->qtd = qtd;

        if (ehci_execute(VAR_0, "queue") == -1) {

            return -1;


        assert(VAR_0->packet.status == USB_RET_ASYNC);

        VAR_0->async = EHCI_ASYNC_INFLIGHT;


leave:

    usb_device_flush_ep_queue(ep->dev, ep);

    return 1;

static int FUNC_0(EHCIPacket *VAR_0)
{ USBEndpoint *ep = VAR_0->packet.ep; EHCIQueue *q = VAR_0->queue; EHCIqtd qtd = VAR_0->qtd; uint32_t qtdaddr; for (;;) { if (NLPTR_TBIT(qtd.next) != 0) { qtdaddr = qtd.next; QTAILQ_FOREACH(VAR_0, &q->packets, next) { if (VAR_0->qtdaddr == qtdaddr) { goto leave; if (get_dwords(q->ehci, NLPTR_GET(qtdaddr),
(uint32_t *) &qtd, sizeof(EHCIqtd) >> 2) < 0) { return -1; ehci_trace_qtd(q, NLPTR_GET(qtdaddr), &qtd); if (!(qtd.token & QTD_TOKEN_ACTIVE)) { VAR_0 = ehci_alloc_packet(q); VAR_0->qtdaddr = qtdaddr; VAR_0->qtd = qtd; if (ehci_execute(VAR_0, "queue") == -1) { return -1; assert(VAR_0->packet.status == USB_RET_ASYNC); VAR_0->async = EHCI_ASYNC_INFLIGHT; leave:
usb_device_flush_ep_queue(ep->dev, ep); return 1;