static void xhci_event(XHCIState *xhci, XHCIEvent *event, int v)

{

    XHCIInterrupter *intr;

    dma_addr_t erdp;

    unsigned int dp_idx;



    if (v >= xhci->numintrs) {

        DPRINTF("intr nr out of range (%d >= %d)\n", v, xhci->numintrs);

        return;

    }

    intr = &xhci->intr[v];



    if (intr->er_full) {

        DPRINTF("xhci_event(): ER full, queueing\n");

        if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {

            DPRINTF("xhci: event queue full, dropping event!\n");

            return;

        }

        intr->ev_buffer[intr->ev_buffer_put++] = *event;

        if (intr->ev_buffer_put == EV_QUEUE) {

            intr->ev_buffer_put = 0;

        }

        return;

    }



    erdp = xhci_addr64(intr->erdp_low, intr->erdp_high);

    if (erdp < intr->er_start ||

        erdp >= (intr->er_start + TRB_SIZE*intr->er_size)) {

        DPRINTF("xhci: ERDP out of bounds: "DMA_ADDR_FMT"\n", erdp);

        DPRINTF("xhci: ER[%d] at "DMA_ADDR_FMT" len %d\n",

                v, intr->er_start, intr->er_size);

        xhci_die(xhci);

        return;

    }



    dp_idx = (erdp - intr->er_start) / TRB_SIZE;

    assert(dp_idx < intr->er_size);



    if ((intr->er_ep_idx+1) % intr->er_size == dp_idx) {

        DPRINTF("xhci_event(): ER full, queueing\n");

#ifndef ER_FULL_HACK

        XHCIEvent full = {ER_HOST_CONTROLLER, CC_EVENT_RING_FULL_ERROR};

        xhci_write_event(xhci, &full);

#endif

        intr->er_full = 1;

        if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {

            DPRINTF("xhci: event queue full, dropping event!\n");

            return;

        }

        intr->ev_buffer[intr->ev_buffer_put++] = *event;

        if (intr->ev_buffer_put == EV_QUEUE) {

            intr->ev_buffer_put = 0;

        }

    } else {

        xhci_write_event(xhci, event, v);

    }



    xhci_intr_raise(xhci, v);

}

static void xhci_event(XHCIState *xhci, XHCIEvent *event, int v)

{

    XHCIInterrupter *intr;

    dma_addr_t erdp;

    unsigned int dp_idx;



    if (v >= xhci->numintrs) {

        DPRINTF("intr nr out of range (%d >= %d)\n", v, xhci->numintrs);

        return;

    }

    intr = &xhci->intr[v];



    if (intr->er_full) {

        DPRINTF("xhci_event(): ER full, queueing\n");

        if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {

            DPRINTF("xhci: event queue full, dropping event!\n");

            return;

        }

        intr->ev_buffer[intr->ev_buffer_put++] = *event;

        if (intr->ev_buffer_put == EV_QUEUE) {

            intr->ev_buffer_put = 0;

        }

        return;

    }



    erdp = xhci_addr64(intr->erdp_low, intr->erdp_high);

    if (erdp < intr->er_start ||

        erdp >= (intr->er_start + TRB_SIZE*intr->er_size)) {

        DPRINTF("xhci: ERDP out of bounds: "DMA_ADDR_FMT"\n", erdp);

        DPRINTF("xhci: ER[%d] at "DMA_ADDR_FMT" len %d\n",

                v, intr->er_start, intr->er_size);

        xhci_die(xhci);

        return;

    }



    dp_idx = (erdp - intr->er_start) / TRB_SIZE;

    assert(dp_idx < intr->er_size);



    if ((intr->er_ep_idx+1) % intr->er_size == dp_idx) {

        DPRINTF("xhci_event(): ER full, queueing\n");

#ifndef ER_FULL_HACK

        XHCIEvent full = {ER_HOST_CONTROLLER, CC_EVENT_RING_FULL_ERROR};

        xhci_write_event(xhci, &full);

#endif

        intr->er_full = 1;

        if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {

            DPRINTF("xhci: event queue full, dropping event!\n");

            return;

        }

        intr->ev_buffer[intr->ev_buffer_put++] = *event;

        if (intr->ev_buffer_put == EV_QUEUE) {

            intr->ev_buffer_put = 0;

        }

    } else {

        xhci_write_event(xhci, event, v);

    }



    xhci_intr_raise(xhci, v);

}

    dma_addr_t erdp;     unsigned int dp_idx;     erdp = xhci_addr64(intr->erdp_low, intr->erdp_high);     if (erdp < intr->er_start ||         erdp >= (intr->er_start + TRB_SIZE*intr->er_size)) {         DPRINTF("xhci: ERDP out of bounds: "DMA_ADDR_FMT"\n", erdp);         DPRINTF("xhci: ER[%d] at "DMA_ADDR_FMT" len %d\n",                 v, intr->er_start, intr->er_size);         xhci_die(xhci);     dp_idx = (erdp - intr->er_start) / TRB_SIZE;     assert(dp_idx < intr->er_size);     if (intr->er_full) { #ifndef ER_FULL_HACK #endif         xhci_write_event(xhci, event, v);     if (intr->er_full) {         DPRINTF("xhci_event(): ER full, queueing\n");         if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {             DPRINTF("xhci: event queue full, dropping event!\n");         intr->ev_buffer[intr->ev_buffer_put++] = *event;         if (intr->ev_buffer_put == EV_QUEUE) {             intr->ev_buffer_put = 0;     if ((intr->er_ep_idx+1) % intr->er_size == dp_idx) {         DPRINTF("xhci_event(): ER full, queueing\n"); #ifndef ER_FULL_HACK         xhci_write_event(xhci, &full); #endif         intr->er_full = 1;         if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {             DPRINTF("xhci: event queue full, dropping event!\n");         intr->ev_buffer[intr->ev_buffer_put++] = *event;         if (intr->ev_buffer_put == EV_QUEUE) {             intr->ev_buffer_put = 0;
static void FUNC_0(XHCIState *VAR_0, XHCIEvent *VAR_1, int VAR_2)

{

    XHCIInterrupter *intr;

    dma_addr_t erdp;

    unsigned int VAR_3;



    if (VAR_2 >= VAR_0->numintrs) {

        DPRINTF("intr nr out of range (%d >= %d)\n", VAR_2, VAR_0->numintrs);

        return;

    }

    intr = &VAR_0->intr[VAR_2];



    if (intr->er_full) {

        DPRINTF("FUNC_0(): ER full, queueing\n");

        if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {

            DPRINTF("VAR_0: VAR_1 queue full, dropping VAR_1!\n");

            return;

        }

        intr->ev_buffer[intr->ev_buffer_put++] = *VAR_1;

        if (intr->ev_buffer_put == EV_QUEUE) {

            intr->ev_buffer_put = 0;

        }

        return;

    }



    erdp = xhci_addr64(intr->erdp_low, intr->erdp_high);

    if (erdp < intr->er_start ||

        erdp >= (intr->er_start + TRB_SIZE*intr->er_size)) {

        DPRINTF("VAR_0: ERDP out of bounds: "DMA_ADDR_FMT"\n", erdp);

        DPRINTF("VAR_0: ER[%d] at "DMA_ADDR_FMT" len %d\n",

                VAR_2, intr->er_start, intr->er_size);

        xhci_die(VAR_0);

        return;

    }



    VAR_3 = (erdp - intr->er_start) / TRB_SIZE;

    assert(VAR_3 < intr->er_size);



    if ((intr->er_ep_idx+1) % intr->er_size == VAR_3) {

        DPRINTF("FUNC_0(): ER full, queueing\n");

#ifndef ER_FULL_HACK

        XHCIEvent full = {ER_HOST_CONTROLLER, CC_EVENT_RING_FULL_ERROR};

        xhci_write_event(VAR_0, &full);

#endif

        intr->er_full = 1;

        if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {

            DPRINTF("VAR_0: VAR_1 queue full, dropping VAR_1!\n");

            return;

        }

        intr->ev_buffer[intr->ev_buffer_put++] = *VAR_1;

        if (intr->ev_buffer_put == EV_QUEUE) {

            intr->ev_buffer_put = 0;

        }

    } else {

        xhci_write_event(VAR_0, VAR_1, VAR_2);

    }



    xhci_intr_raise(VAR_0, VAR_2);

}

static void FUNC_0(XHCIState *VAR_0, XHCIEvent *VAR_1, int VAR_2)
{ XHCIInterrupter *intr; dma_addr_t erdp; unsigned int VAR_3; if (VAR_2 >= VAR_0->numintrs) { DPRINTF("intr nr out of range (%d >= %d)\n", VAR_2, VAR_0->numintrs); return; } intr = &VAR_0->intr[VAR_2]; if (intr->er_full) { DPRINTF("FUNC_0(): ER full, queueing\n"); if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) { DPRINTF("VAR_0: VAR_1 queue full, dropping VAR_1!\n"); return; } intr->ev_buffer[intr->ev_buffer_put++] = *VAR_1; if (intr->ev_buffer_put == EV_QUEUE) { intr->ev_buffer_put = 0; } return; } erdp = xhci_addr64(intr->erdp_low, intr->erdp_high); if (erdp < intr->er_start ||
erdp >= (intr->er_start + TRB_SIZE*intr->er_size)) { DPRINTF("VAR_0: ERDP out of bounds: "DMA_ADDR_FMT"\n", erdp); DPRINTF("VAR_0: ER[%d] at "DMA_ADDR_FMT" len %d\n",
VAR_2, intr->er_start, intr->er_size); xhci_die(VAR_0); return; } VAR_3 = (erdp - intr->er_start) / TRB_SIZE; assert(VAR_3 < intr->er_size); if ((intr->er_ep_idx+1) % intr->er_size == VAR_3) { DPRINTF("FUNC_0(): ER full, queueing\n"); #ifndef ER_FULL_HACK
XHCIEvent full = {ER_HOST_CONTROLLER, CC_EVENT_RING_FULL_ERROR}; xhci_write_event(VAR_0, &full); #endif
intr->er_full = 1; if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) { DPRINTF("VAR_0: VAR_1 queue full, dropping VAR_1!\n"); return; } intr->ev_buffer[intr->ev_buffer_put++] = *VAR_1; if (intr->ev_buffer_put == EV_QUEUE) { intr->ev_buffer_put = 0; } } else { xhci_write_event(VAR_0, VAR_1, VAR_2); } xhci_intr_raise(VAR_0, VAR_2); }