diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2013-04-24 10:11:22 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2013-06-03 11:37:51 +0200 |
commit | 003e15a180373048f0c1f4df0bfe303746eb2676 (patch) | |
tree | 3f341e74536591fe07a14865c5f518adde08e88d /hw | |
parent | 492b21f63fa655e0271abef4784cc337dd1d3fe7 (diff) | |
download | qemu-003e15a180373048f0c1f4df0bfe303746eb2676.zip qemu-003e15a180373048f0c1f4df0bfe303746eb2676.tar.gz qemu-003e15a180373048f0c1f4df0bfe303746eb2676.tar.bz2 |
xhci: add xhci_init_epctx
Factor out endpoint context initialization to a separate function.
xhci live migration will need that too, in post_load.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/usb/hcd-xhci.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 5084e52..9b90067 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1218,26 +1218,11 @@ static XHCIEPContext *xhci_alloc_epctx(XHCIState *xhci, return epctx; } -static TRBCCode xhci_enable_ep(XHCIState *xhci, unsigned int slotid, - unsigned int epid, dma_addr_t pctx, - uint32_t *ctx) +static void xhci_init_epctx(XHCIEPContext *epctx, + dma_addr_t pctx, uint32_t *ctx) { - XHCISlot *slot; - XHCIEPContext *epctx; dma_addr_t dequeue; - trace_usb_xhci_ep_enable(slotid, epid); - assert(slotid >= 1 && slotid <= xhci->numslots); - assert(epid >= 1 && epid <= 31); - - slot = &xhci->slots[slotid-1]; - if (slot->eps[epid-1]) { - xhci_disable_ep(xhci, slotid, epid); - } - - epctx = xhci_alloc_epctx(xhci, slotid, epid); - slot->eps[epid-1] = epctx; - dequeue = xhci_addr64(ctx[2] & ~0xf, ctx[3]); epctx->type = (ctx[1] >> EP_TYPE_SHIFT) & EP_TYPE_MASK; @@ -1252,11 +1237,33 @@ static TRBCCode xhci_enable_ep(XHCIState *xhci, unsigned int slotid, if (epctx->max_pstreams) { xhci_alloc_streams(epctx, dequeue); } else { - xhci_ring_init(xhci, &epctx->ring, dequeue); + xhci_ring_init(epctx->xhci, &epctx->ring, dequeue); epctx->ring.ccs = ctx[2] & 1; } epctx->interval = 1 << (ctx[0] >> 16) & 0xff; +} + +static TRBCCode xhci_enable_ep(XHCIState *xhci, unsigned int slotid, + unsigned int epid, dma_addr_t pctx, + uint32_t *ctx) +{ + XHCISlot *slot; + XHCIEPContext *epctx; + + trace_usb_xhci_ep_enable(slotid, epid); + assert(slotid >= 1 && slotid <= xhci->numslots); + assert(epid >= 1 && epid <= 31); + + slot = &xhci->slots[slotid-1]; + if (slot->eps[epid-1]) { + xhci_disable_ep(xhci, slotid, epid); + } + + epctx = xhci_alloc_epctx(xhci, slotid, epid); + slot->eps[epid-1] = epctx; + xhci_init_epctx(epctx, pctx, ctx); + epctx->mfindex_last = 0; epctx->state = EP_RUNNING; |