func: static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int uint64_t pictx, bool bsr) USBPort * uport ; USBDevice * dev ; dma_addr_t ictx , octx , dcbaap ; uint64_t poctx ; uint32_t ictl_ctx [ 2 ] ; uint32_t slot_ctx [ 4 ] ; uint32_t ep0_ctx [ 5 ] ; int i ; TRBCCode res ; dcbaap = xhci_addr64 ( xhci -> dcbaap_low , xhci -> dcbaap_high ); static inline dma_addr_t xhci_addr64(uint32_t low, uint32_t high) if ( sizeof ( dma_addr_t ) == 4 )  return low ; return low | ( ( ( dma_addr_t ) high << 16 ) << 16 ) ; poctx = ldq_le_pci_dma ( PCI_DEVICE ( xhci ) , dcbaap + 8 * slotid ); octx = xhci_mask64 ( poctx ); static inline dma_addr_t xhci_mask64(uint64_t addr) if ( sizeof ( dma_addr_t ) == 4 )  return addr & 0xffffffff ; return addr ; if ( ictl_ctx [ 0 ] != 0x0 || ictl_ctx [ 1 ] != 0x3 )  uport = xhci_lookup_uport ( xhci , slot_ctx ); static USBPort *xhci_lookup_uport(XHCIState *xhci, uint32_t *slot_ctx) USBPort * uport ; char path [ 32 ] ; int i , pos , port ; port = ( slot_ctx [ 1 ] >> 16 ) & 0xFF; if ( port < 1 || port > xhci -> numports )  return NULL ; if ( strcmp ( uport -> path , path ) == 0 )  return uport ; return NULL ; if ( uport == NULL )  dev = uport -> dev; if ( ! dev || ! dev -> attached )  for (i = 0; i < xhci->numslots; i++) if ( i == slotid - 1 )  if ( xhci -> slots [ i ] . uport == uport )  res = xhci_enable_ep ( xhci , slotid , 1 , octx + 32 , ep0_ctx ); static TRBCCode xhci_enable_ep(XHCIState *xhci, unsigned int unsigned int epid, dma_addr_t uint32_t *ctx) XHCIEPContext * epctx ; epctx = xhci_alloc_epctx ( xhci , slotid , epid ); xhci_init_epctx ( epctx , pctx , ctx ); static void xhci_init_epctx(XHCIEPContext dma_addr_t pctx, uint32_t *ctx) dma_addr_t dequeue ; dequeue = xhci_addr64 ( ctx [ 2 ] & ~0xf , ctx [ 3 ] ); epctx -> type = ( ctx [ 1 ] >> EP_TYPE_SHIFT ) & EP_TYPE_MASK; epctx -> pctx = pctx; epctx -> max_psize = ctx [ 1 ] >> 16; epctx -> max_psize *= 1 + ( ( ctx [ 1 ] >> 8 ) & 0xff ); epctx -> max_pstreams = ( ctx [ 0 ] >> 10 ) & epctx -> xhci -> max_pstreams_mask; epctx -> lsa = ( ctx [ 0 ] >> 15 ) & 1; if ( epctx -> max_pstreams )  xhci_alloc_streams ( epctx , dequeue ); static void xhci_alloc_streams(XHCIEPContext *epctx, dma_addr_t base) assert ( epctx -> pstreams == NULL ); 