Changeset cb89430 in mainline for uspace/drv/bus/usb/xhci/trb_ring.h


Ignore:
Timestamp:
2017-06-22T13:59:15Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e4d7363
Parents:
62ba2cbe
Message:

xhci: event rings && hc initialization (WIP)

File:
1 edited

Legend:

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

    r62ba2cbe rcb89430  
    4545#include <adt/list.h>
    4646#include <libarch/config.h>
    47 #include "hw_struct/trb.h"
    4847
    4948typedef struct trb_segment trb_segment_t;
     49typedef struct xhci_hc xhci_hc_t;
     50typedef struct xhci_trb xhci_trb_t;
     51typedef struct xhci_erst_entry xhci_erst_entry_t;
    5052
    5153/**
     
    5456typedef struct xhci_trb_ring {
    5557        list_t segments;                /* List of assigned segments */
     58        int segment_count;              /* Number of segments assigned */
    5659
    5760        /*
     
    6770} xhci_trb_ring_t;
    6871
    69 /**
    70  * Initializes the ring.
    71  * Allocates one page as the first segment.
    72  */
    73 int trb_ring_init(xhci_trb_ring_t *ring);
    74 int trb_ring_fini(xhci_trb_ring_t *ring);
     72int xhci_trb_ring_init(xhci_trb_ring_t *, xhci_hc_t *);
     73int xhci_trb_ring_fini(xhci_trb_ring_t *);
     74int xhci_trb_ring_enqueue(xhci_trb_ring_t *, xhci_trb_t *);
    7575
    7676/**
    77  * Enqueue a TD composed of TRBs.
    78  *
    79  * This will copy all TRBs chained together into the ring. The cycle flag in
    80  * TRBs may be changed.
    81  *
    82  * The chained TRBs must be contiguous in memory, and must not contain Link TRBs.
    83  *
    84  * We cannot avoid the copying, because the TRB in ring should be updated atomically.
    85  *
    86  * @param td the first TRB of TD
    87  * @return EOK on success,
    88  *         EAGAIN when the ring is too full to fit all TRBs (temporary)
     77 * Get the initial value to fill into CRCR.
    8978 */
    90 int trb_ring_enqueue(xhci_trb_ring_t *ring, xhci_trb_t *td);
     79static inline uintptr_t xhci_trb_ring_get_dequeue_ptr(xhci_trb_ring_t *ring)
     80{
     81        return ring->dequeue;
     82}
    9183
    9284/**
     
    9486 * pointer inside the ring. Otherwise, the ring will soon show up as full.
    9587 */
    96 void trb_ring_update_dequeue(xhci_trb_ring_t *ring, uintptr_t dequeue);
     88void xhci_trb_ring_update_dequeue(xhci_trb_ring_t *, uintptr_t);
     89uintptr_t xhci_trb_ring_get_dequeue_ptr(xhci_trb_ring_t *);
    9790
     91/**
     92 * A TRB ring of which the software is a consumer (event rings).
     93 */
     94typedef struct xhci_event_ring {
     95        list_t segments;                /* List of assigned segments */
     96        int segment_count;              /* Number of segments assigned */
     97
     98        trb_segment_t *dequeue_segment; /* Current segment of the dequeue ptr */
     99        xhci_trb_t *dequeue_trb;        /* Next TRB to be processed */
     100        uintptr_t dequeue_ptr;          /* Physical address of the ERDP to be reported to the HC */
     101
     102        xhci_erst_entry_t *erst;        /* ERST given to the HC */
     103
     104        bool ccs;                       /* Consumer Cycle State: section 4.9.2 */
     105} xhci_event_ring_t;
     106
     107int xhci_event_ring_init(xhci_event_ring_t *, xhci_hc_t *);
     108int xhci_event_ring_fini(xhci_event_ring_t *);
     109int xhci_event_ring_dequeue(xhci_event_ring_t *, xhci_trb_t *);
    98110
    99111#endif
Note: See TracChangeset for help on using the changeset viewer.