Ignore:
Timestamp:
2018-01-19T21:04:32Z (6 years ago)
Author:
Jenda <jenda.jzqk73@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
726af29
Parents:
c6f82e5
Message:

Handling HCs with 32 or 64-bytes context size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/hw_struct/context.h

    rc6f82e5 r7ec7b7e  
    175175
    176176/**
     177 * Handling HCs with 32 or 64-bytes context size (CSZ)
     178 */
     179#define XHCI_CTX_SIZE_SMALL 32
     180#define XHCI_ONE_CTX_SIZE(hc) (XHCI_CTX_SIZE_SMALL << hc->csz)
     181#define XHCI_SLOT_CTX_OFFSET 0
     182#define XHCI_EP_ARRAY_OFFSET 1
     183#define XHCI_DEVICE_CTX_SIZE(hc) ((XHCI_EP_ARRAY_OFFSET + XHCI_EP_COUNT) * XHCI_ONE_CTX_SIZE(hc))
     184
     185/**
    177186 * Device context: section 6.2.1
    178187 */
     188#define XHCI_GET_SLOT_CTX(dev_ctx, hc) (xhci_slot_ctx_t *)((char*)dev_ctx + XHCI_SLOT_CTX_OFFSET * XHCI_ONE_CTX_SIZE(hc))
     189#define XHCI_GET_EP_CTX(dev_ctx, hc, dci) (xhci_ep_ctx_t *)((char*)dev_ctx + (dci + XHCI_EP_ARRAY_OFFSET) * XHCI_ONE_CTX_SIZE(hc))
     190
    179191typedef struct xhci_device_ctx {
    180         xhci_slot_ctx_t slot_ctx;
    181         xhci_ep_ctx_t endpoint_ctx[XHCI_EP_COUNT];
    182 } __attribute__((packed)) xhci_device_ctx_t;
     192} xhci_device_ctx_t;
    183193
    184194/**
     
    228238 * Input context: section 6.2.5
    229239 */
     240
     241#define XHCI_CTRL_CTX_OFFSET 0
     242#define XHCI_DEVICE_CTX_OFFSET 1
     243#define XHCI_INPUT_CTX_SIZE(hc) (XHCI_DEVICE_CTX_OFFSET * XHCI_ONE_CTX_SIZE(hc) + XHCI_DEVICE_CTX_SIZE(hc))
     244#define XHCI_GET_CTRL_CTX(ictx, hc) (xhci_input_ctrl_ctx_t*)((char*)ictx + XHCI_CTRL_CTX_OFFSET * XHCI_ONE_CTX_SIZE(hc))
     245#define XHCI_GET_DEVICE_CTX(ictx, hc) (xhci_device_ctx_t *)((char*)ictx + XHCI_DEVICE_CTX_OFFSET * XHCI_ONE_CTX_SIZE(hc))
     246
    230247typedef struct xhci_input_ctx {
    231         xhci_input_ctrl_ctx_t ctrl_ctx;
    232         xhci_slot_ctx_t slot_ctx;
    233         xhci_ep_ctx_t endpoint_ctx[XHCI_EP_COUNT];
    234 } __attribute__((packed)) xhci_input_ctx_t;
     248} xhci_input_ctx_t;
    235249
    236250/**
Note: See TracChangeset for help on using the changeset viewer.