Changeset ef1a3a8 in mainline


Ignore:
Timestamp:
2017-10-29T11:53:45Z (7 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a312d8f
Parents:
d33dc780
Message:

Added memory structure for stream TRB rings. Implemented their initialization. Fixed white space.

Location:
uspace/drv/bus/usb/xhci
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/endpoint.c

    rd33dc780 ref1a3a8  
    116116static void initialize_primary_streams(xhci_hc_t *hc, xhci_endpoint_t *xhci_ep, unsigned count) {
    117117        for (size_t index = 0; index < count; ++index) {
    118                 // Create trb ring for every primary stream
    119                 // Store it somewhere
    120                 // Set the dequeue pointer in stream context structure
    121 
    122                 // Set to linear stream array
    123                 XHCI_STREAM_SCT_SET(xhci_ep->primary_stream_ctx_array[index], 1);
     118                xhci_stream_ctx_t *ctx = &xhci_ep->primary_stream_ctx_array[index];
     119                xhci_trb_ring_t *ring = &xhci_ep->primary_stream_rings[index];
     120
     121                /* Init and register TRB ring for every primary stream */
     122                xhci_trb_ring_init(ring);
     123                XHCI_STREAM_DEQ_PTR_SET(*ctx, ring->dequeue);
     124
     125                /* Set to linear stream array */
     126                XHCI_STREAM_SCT_SET(*ctx, 1);
    124127        }
    125128}
     
    151154        uint8_t max_psa_size = 2 << XHCI_REG_RD(hc->cap_regs, XHCI_CAP_MAX_PSA_SIZE);
    152155        if (count > max_psa_size) {
    153                 // We don't support secondary stream arrays yet, so we just give up for this
     156                // FIXME: We don't support secondary stream arrays yet, so we just give up for this
    154157                return ENOTSUP;
    155158        }
     
    169172                }
    170173
     174                xhci_ep->primary_stream_rings = calloc(count, sizeof(xhci_trb_ring_t));
     175                if (!xhci_ep->primary_stream_rings) {
     176                        free32(xhci_ep->primary_stream_ctx_array);
     177                        return ENOMEM;
     178                }
     179
    171180                // FIXME: count should be rounded to nearest power of 2 for xHC, workaround for now
    172181                count = 1024;
     
    182191                return hc_add_endpoint(hc, dev->slot_id, xhci_endpoint_index(xhci_ep), &ep_ctx);
    183192        }
    184         // Complex stuff not supported yet
     193        // FIXME: Complex stuff not supported yet
    185194        return ENOTSUP;
    186195}
  • uspace/drv/bus/usb/xhci/endpoint.h

    rd33dc780 ref1a3a8  
    7474        xhci_transfer_t active_transfer;
    7575
    76         /** Primary stream context array (or NULL if endpoint doesn't use streams) */
     76        /** Primary stream context array (or NULL if endpoint doesn't use streams). */
    7777        xhci_stream_ctx_t *primary_stream_ctx_array;
    7878
    79         /** Size of the allocated primary stream context array. */
     79        /** Primary stream ring array (or NULL if endpoint doesn't use streams). */
     80        xhci_trb_ring_t *primary_stream_rings;
     81
     82        /** Size of the allocated primary stream context array (and ring array). */
    8083        uint16_t primary_stream_ctx_array_size;
    8184
  • uspace/drv/bus/usb/xhci/hw_struct/context.h

    rd33dc780 ref1a3a8  
    169169#define XHCI_STREAM_SCT_SET(ctx, val) \
    170170        xhci_qword_set_bits(&(ctx).data[0], val, 3, 1)
     171#define XHCI_STREAM_DEQ_PTR_SET(ctx, val) \
     172        xhci_qword_set_bits(&(ctx).data[0], (val >> 4), 63, 4)
    171173} __attribute__((packed)) xhci_stream_ctx_t;
    172174
  • uspace/drv/bus/usb/xhci/transfers.c

    rd33dc780 ref1a3a8  
    324324        if (!xhci_ep->ring.segment_count) {
    325325                usb_log_error("Ring not initialized for endpoint " XHCI_EP_FMT,
    326                     XHCI_EP_ARGS(*xhci_ep));
     326                    XHCI_EP_ARGS(*xhci_ep));
    327327                return EINVAL;
    328328        }
Note: See TracChangeset for help on using the changeset viewer.