Changeset 7ec7b7e in mainline for uspace/drv/bus/usb/xhci/hc.c
- Timestamp:
- 2018-01-19T21:04:32Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 726af29
- Parents:
- c6f82e5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.c
rc6f82e5 r7ec7b7e 223 223 224 224 hc->ac64 = XHCI_REG_RD(hc->cap_regs, XHCI_CAP_AC64); 225 hc->csz = XHCI_REG_RD(hc->cap_regs, XHCI_CAP_CSZ); 225 226 hc->max_slots = XHCI_REG_RD(hc->cap_regs, XHCI_CAP_MAX_SLOTS); 226 227 … … 723 724 724 725 /* Prepare memory for the context */ 725 if ((err = dma_buffer_alloc(&dev->dev_ctx, sizeof(xhci_device_ctx_t))))726 if ((err = dma_buffer_alloc(&dev->dev_ctx, XHCI_DEVICE_CTX_SIZE(hc)))) 726 727 return err; 727 memset(dev->dev_ctx.virt, 0, sizeof(xhci_device_ctx_t));728 memset(dev->dev_ctx.virt, 0, XHCI_DEVICE_CTX_SIZE(hc)); 728 729 729 730 /* Get the slot number */ … … 807 808 static int create_configure_ep_input_ctx(xhci_device_t *dev, dma_buffer_t *dma_buf) 808 809 { 809 const int err = dma_buffer_alloc(dma_buf, sizeof(xhci_input_ctx_t)); 810 const xhci_hc_t * hc = bus_to_hc(dev->base.bus); 811 const int err = dma_buffer_alloc(dma_buf, XHCI_INPUT_CTX_SIZE(hc)); 810 812 if (err) 811 813 return err; 812 814 813 815 xhci_input_ctx_t *ictx = dma_buf->virt; 814 memset(ictx, 0, sizeof(xhci_input_ctx_t));816 memset(ictx, 0, XHCI_INPUT_CTX_SIZE(hc)); 815 817 816 818 // Quoting sec. 4.6.5 and 4.6.6: A1, D0, D1 are down (already zeroed), A0 is up. 817 XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, 0); 818 xhci_setup_slot_context(dev, &ictx->slot_ctx); 819 XHCI_INPUT_CTRL_CTX_ADD_SET(*XHCI_GET_CTRL_CTX(ictx, hc), 0); 820 xhci_slot_ctx_t *slot_ctx = XHCI_GET_SLOT_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc); 821 xhci_setup_slot_context(dev, slot_ctx); 819 822 820 823 return EOK; … … 846 849 847 850 /* Copy endpoint 0 context and set A1 flag. */ 848 XHCI_INPUT_CTRL_CTX_ADD_SET( ictx->ctrl_ctx, 1);849 xhci_ setup_endpoint_context(ep0, &ictx->endpoint_ctx[0]);850 851 XHCI_INPUT_CTRL_CTX_ADD_SET(*XHCI_GET_CTRL_CTX(ictx, hc), 1); 852 xhci_ep_ctx_t *ep_ctx = XHCI_GET_EP_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc, 0); 853 xhci_setup_endpoint_context(ep0, ep_ctx); 851 854 /* Address device needs Ctx entries set to 1 only */ 852 xhci_slot_ctx_t *slot_ctx = &ictx->slot_ctx;855 xhci_slot_ctx_t *slot_ctx = XHCI_GET_SLOT_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc); 853 856 XHCI_SLOT_CTX_ENTRIES_SET(*slot_ctx, 1); 854 857 … … 857 860 return err; 858 861 859 xhci_device_ctx_t *dev _ctx = dev->dev_ctx.virt;860 dev->base.address = XHCI_SLOT_DEVICE_ADDRESS( dev_ctx->slot_ctx);862 xhci_device_ctx_t *device_ctx = dev->dev_ctx.virt; 863 dev->base.address = XHCI_SLOT_DEVICE_ADDRESS(*XHCI_GET_SLOT_CTX(device_ctx, hc)); 861 864 usb_log_debug2("Obtained USB address: %d.", dev->base.address); 862 865 … … 911 914 912 915 xhci_input_ctx_t *ictx = ictx_dma_buf.virt; 913 XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, ep_idx + 1); /* Preceded by slot ctx */914 memcpy(&ictx->endpoint_ctx[ep_idx], ep_ctx, sizeof(xhci_ep_ctx_t));915 916 916 917 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 918 XHCI_INPUT_CTRL_CTX_ADD_SET(*XHCI_GET_CTRL_CTX(ictx, hc), ep_idx + 1); /* Preceded by slot ctx */ 919 920 xhci_ep_ctx_t *_ep_ctx = XHCI_GET_EP_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc, ep_idx); 921 memcpy(_ep_ctx, ep_ctx, XHCI_ONE_CTX_SIZE(hc)); 922 917 923 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf); 918 924 } … … 932 938 return err; 933 939 940 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 934 941 xhci_input_ctx_t *ictx = ictx_dma_buf.virt; 935 XHCI_INPUT_CTRL_CTX_DROP_SET(ictx->ctrl_ctx, ep_idx + 1); /* Preceded by slot ctx */ 936 937 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 942 XHCI_INPUT_CTRL_CTX_DROP_SET(*XHCI_GET_CTRL_CTX(ictx, hc), ep_idx + 1); /* Preceded by slot ctx */ 943 938 944 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf); 939 945 } … … 950 956 { 951 957 dma_buffer_t ictx_dma_buf; 952 const int err = dma_buffer_alloc(&ictx_dma_buf, sizeof(xhci_input_ctx_t)); 958 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 959 960 const int err = dma_buffer_alloc(&ictx_dma_buf, XHCI_INPUT_CTX_SIZE(hc)); 953 961 if (err) 954 962 return err; 955 963 956 964 xhci_input_ctx_t *ictx = ictx_dma_buf.virt; 957 memset(ictx, 0, sizeof(xhci_input_ctx_t));958 959 XHCI_INPUT_CTRL_CTX_ADD_SET( ictx->ctrl_ctx, ep_idx + 1);960 memcpy(&ictx->endpoint_ctx[ep_idx], ep_ctx, sizeof(xhci_ep_ctx_t));961 962 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 965 memset(ictx, 0, XHCI_INPUT_CTX_SIZE(hc)); 966 967 XHCI_INPUT_CTRL_CTX_ADD_SET(*XHCI_GET_CTRL_CTX(ictx, hc), ep_idx + 1); 968 xhci_ep_ctx_t *_ep_ctx = XHCI_GET_EP_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc, 0); 969 memcpy(_ep_ctx, ep_ctx, sizeof(xhci_ep_ctx_t)); 970 963 971 return xhci_cmd_sync_inline(hc, EVALUATE_CONTEXT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf); 964 972 }
Note:
See TracChangeset
for help on using the changeset viewer.