static int ehci_execute(EHCIPacket *p, const char *action)

{

    USBEndpoint *ep;

    int ret;

    int endp;



    if (!(p->qtd.token & QTD_TOKEN_ACTIVE)) {

        fprintf(stderr, "Attempting to execute inactive qtd\n");

        return USB_RET_PROCERR;

    }



    p->tbytes = (p->qtd.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;

    if (p->tbytes > BUFF_SIZE) {

        ehci_trace_guest_bug(p->queue->ehci,

                             "guest requested more bytes than allowed");

        return USB_RET_PROCERR;

    }



    p->pid = (p->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;

    switch (p->pid) {

    case 0:

        p->pid = USB_TOKEN_OUT;

        break;

    case 1:

        p->pid = USB_TOKEN_IN;

        break;

    case 2:

        p->pid = USB_TOKEN_SETUP;

        break;

    default:

        fprintf(stderr, "bad token\n");

        break;

    }



    if (ehci_init_transfer(p) != 0) {

        return USB_RET_PROCERR;

    }



    endp = get_field(p->queue->qh.epchar, QH_EPCHAR_EP);

    ep = usb_ep_get(p->queue->dev, p->pid, endp);



    usb_packet_setup(&p->packet, p->pid, ep, p->qtdaddr);

    usb_packet_map(&p->packet, &p->sgl);



    trace_usb_ehci_packet_action(p->queue, p, action);

    ret = usb_handle_packet(p->queue->dev, &p->packet);

    DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd "

            "(total %d) endp %x ret %d\n",

            q->qhaddr, q->qh.next, q->qtdaddr, q->pid,

            q->packet.iov.size, q->tbytes, endp, ret);



    if (ret > BUFF_SIZE) {

        fprintf(stderr, "ret from usb_handle_packet > BUFF_SIZE\n");

        return USB_RET_PROCERR;

    }



    return ret;

}

static int ehci_execute(EHCIPacket *p, const char *action)

{

    USBEndpoint *ep;

    int ret;

    int endp;



    if (!(p->qtd.token & QTD_TOKEN_ACTIVE)) {

        fprintf(stderr, "Attempting to execute inactive qtd\n");

        return USB_RET_PROCERR;

    }



    p->tbytes = (p->qtd.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;

    if (p->tbytes > BUFF_SIZE) {

        ehci_trace_guest_bug(p->queue->ehci,

                             "guest requested more bytes than allowed");

        return USB_RET_PROCERR;

    }



    p->pid = (p->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;

    switch (p->pid) {

    case 0:

        p->pid = USB_TOKEN_OUT;

        break;

    case 1:

        p->pid = USB_TOKEN_IN;

        break;

    case 2:

        p->pid = USB_TOKEN_SETUP;

        break;

    default:

        fprintf(stderr, "bad token\n");

        break;

    }



    if (ehci_init_transfer(p) != 0) {

        return USB_RET_PROCERR;

    }



    endp = get_field(p->queue->qh.epchar, QH_EPCHAR_EP);

    ep = usb_ep_get(p->queue->dev, p->pid, endp);



    usb_packet_setup(&p->packet, p->pid, ep, p->qtdaddr);

    usb_packet_map(&p->packet, &p->sgl);



    trace_usb_ehci_packet_action(p->queue, p, action);

    ret = usb_handle_packet(p->queue->dev, &p->packet);

    DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd "

            "(total %d) endp %x ret %d\n",

            q->qhaddr, q->qh.next, q->qtdaddr, q->pid,

            q->packet.iov.size, q->tbytes, endp, ret);



    if (ret > BUFF_SIZE) {

        fprintf(stderr, "ret from usb_handle_packet > BUFF_SIZE\n");

        return USB_RET_PROCERR;

    }



    return ret;

}

    if (ehci_init_transfer(p) != 0) {         return USB_RET_PROCERR;     usb_packet_setup(&p->packet, p->pid, ep, p->qtdaddr);     usb_packet_map(&p->packet, &p->sgl);
static int FUNC_0(EHCIPacket *VAR_0, const char *VAR_1)

{

    USBEndpoint *ep;

    int VAR_2;

    int VAR_3;



    if (!(VAR_0->qtd.token & QTD_TOKEN_ACTIVE)) {

        fprintf(stderr, "Attempting to execute inactive qtd\n");

        return USB_RET_PROCERR;

    }



    VAR_0->tbytes = (VAR_0->qtd.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;

    if (VAR_0->tbytes > BUFF_SIZE) {

        ehci_trace_guest_bug(VAR_0->queue->ehci,

                             "guest requested more bytes than allowed");

        return USB_RET_PROCERR;

    }



    VAR_0->pid = (VAR_0->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;

    switch (VAR_0->pid) {

    case 0:

        VAR_0->pid = USB_TOKEN_OUT;

        break;

    case 1:

        VAR_0->pid = USB_TOKEN_IN;

        break;

    case 2:

        VAR_0->pid = USB_TOKEN_SETUP;

        break;

    default:

        fprintf(stderr, "bad token\n");

        break;

    }



    if (ehci_init_transfer(VAR_0) != 0) {

        return USB_RET_PROCERR;

    }



    VAR_3 = get_field(VAR_0->queue->qh.epchar, QH_EPCHAR_EP);

    ep = usb_ep_get(VAR_0->queue->dev, VAR_0->pid, VAR_3);



    usb_packet_setup(&VAR_0->packet, VAR_0->pid, ep, VAR_0->qtdaddr);

    usb_packet_map(&VAR_0->packet, &VAR_0->sgl);



    trace_usb_ehci_packet_action(VAR_0->queue, VAR_0, VAR_1);

    VAR_2 = usb_handle_packet(VAR_0->queue->dev, &VAR_0->packet);

    DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd "

            "(total %d) VAR_3 %x VAR_2 %d\n",

            q->qhaddr, q->qh.next, q->qtdaddr, q->pid,

            q->packet.iov.size, q->tbytes, VAR_3, VAR_2);



    if (VAR_2 > BUFF_SIZE) {

        fprintf(stderr, "VAR_2 from usb_handle_packet > BUFF_SIZE\n");

        return USB_RET_PROCERR;

    }



    return VAR_2;

}

static int FUNC_0(EHCIPacket *VAR_0, const char *VAR_1)
{ USBEndpoint *ep; int VAR_2; int VAR_3; if (!(VAR_0->qtd.token & QTD_TOKEN_ACTIVE)) { fprintf(stderr, "Attempting to execute inactive qtd\n"); return USB_RET_PROCERR; } VAR_0->tbytes = (VAR_0->qtd.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH; if (VAR_0->tbytes > BUFF_SIZE) { ehci_trace_guest_bug(VAR_0->queue->ehci,
"guest requested more bytes than allowed"); return USB_RET_PROCERR; } VAR_0->pid = (VAR_0->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH; switch (VAR_0->pid) { case 0:
VAR_0->pid = USB_TOKEN_OUT; break; case 1:
VAR_0->pid = USB_TOKEN_IN; break; case 2:
VAR_0->pid = USB_TOKEN_SETUP; break; default:
fprintf(stderr, "bad token\n"); break; } if (ehci_init_transfer(VAR_0) != 0) { return USB_RET_PROCERR; } VAR_3 = get_field(VAR_0->queue->qh.epchar, QH_EPCHAR_EP); ep = usb_ep_get(VAR_0->queue->dev, VAR_0->pid, VAR_3); usb_packet_setup(&VAR_0->packet, VAR_0->pid, ep, VAR_0->qtdaddr); usb_packet_map(&VAR_0->packet, &VAR_0->sgl); trace_usb_ehci_packet_action(VAR_0->queue, VAR_0, VAR_1); VAR_2 = usb_handle_packet(VAR_0->queue->dev, &VAR_0->packet); DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd "
"(total %d) VAR_3 %x VAR_2 %d\n",
q->qhaddr, q->qh.next, q->qtdaddr, q->pid,
q->packet.iov.size, q->tbytes, VAR_3, VAR_2); if (VAR_2 > BUFF_SIZE) { fprintf(stderr, "VAR_2 from usb_handle_packet > BUFF_SIZE\n"); return USB_RET_PROCERR; } return VAR_2; }