Ignore:
Timestamp:
2011-03-16T18:50:17Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42a3a57
Parents:
3e7b7cd (diff), fcf07e6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge from usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h

    r3e7b7cd r72af8da  
    11/*
    2  * Copyright (c) 2010 Jan Vesely
     2 * Copyright (c) 2011 Jan Vesely
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
     
    4545
    4646        volatile uint32_t status;
    47 
    4847#define TD_STATUS_RESERVED_MASK 0xc000f800
    4948#define TD_STATUS_SPD_FLAG ( 1 << 29 )
    5049#define TD_STATUS_ERROR_COUNT_POS ( 27 )
    5150#define TD_STATUS_ERROR_COUNT_MASK ( 0x3 )
    52 #define TD_STATUS_ERROR_COUNT_DEFAULT 3
    5351#define TD_STATUS_LOW_SPEED_FLAG ( 1 << 26 )
    5452#define TD_STATUS_ISOCHRONOUS_FLAG ( 1 << 25 )
    55 #define TD_STATUS_COMPLETE_INTERRUPT_FLAG ( 1 << 24 )
     53#define TD_STATUS_IOC_FLAG ( 1 << 24 )
    5654
    5755#define TD_STATUS_ERROR_ACTIVE ( 1 << 23 )
     
    7068
    7169        volatile uint32_t device;
    72 
    7370#define TD_DEVICE_MAXLEN_POS 21
    7471#define TD_DEVICE_MAXLEN_MASK ( 0x7ff )
     
    8582
    8683        /* there is 16 bytes of data available here, according to UHCI
    87          * Design guide, according to linux kernel the hardware does not care
    88          * we don't use it anyway
     84         * Design guide, according to linux kernel the hardware does not care,
     85         * it just needs to be aligned, we don't use it anyway
    8986         */
    90 } __attribute__((packed)) transfer_descriptor_t;
     87} __attribute__((packed)) td_t;
    9188
    9289
    93 void transfer_descriptor_init(transfer_descriptor_t *instance,
    94     int error_count, size_t size, bool toggle, bool isochronous, bool low_speed,
    95     usb_target_t target, int pid, void *buffer, transfer_descriptor_t * next);
     90void td_init(td_t *instance, int error_count, size_t size, bool toggle,
     91    bool iso, bool low_speed, usb_target_t target, usb_packet_id pid,
     92    void *buffer, td_t *next);
    9693
    97 int transfer_descriptor_status(transfer_descriptor_t *instance);
     94int td_status(td_t *instance);
    9895
    99 static inline size_t transfer_descriptor_actual_size(
    100     transfer_descriptor_t *instance)
     96void td_print_status(td_t *instance);
     97/*----------------------------------------------------------------------------*/
     98/** Helper function for parsing actual size out of TD.
     99 *
     100 * @param[in] instance TD structure to use.
     101 * @return Parsed actual size.
     102 */
     103static inline size_t td_act_size(td_t *instance)
    101104{
    102105        assert(instance);
     106        const uint32_t s = instance->status;
     107        return ((s >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK;
     108}
     109/*----------------------------------------------------------------------------*/
     110/** Check whether less than max data were recieved and packet is marked as SPD.
     111 *
     112 * @param[in] instance TD structure to use.
     113 * @return True if packet is short (less than max bytes and SPD set), false
     114 *     otherwise.
     115 */
     116static inline bool td_is_short(td_t *instance)
     117{
     118        const size_t act_size = td_act_size(instance);
     119        const size_t max_size =
     120            ((instance->device >> TD_DEVICE_MAXLEN_POS) + 1)
     121            & TD_DEVICE_MAXLEN_MASK;
    103122        return
    104             ((instance->status >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK;
     123            (instance->status | TD_STATUS_SPD_FLAG) && act_size < max_size;
    105124}
    106 
    107 static inline bool transfer_descriptor_is_active(
    108     transfer_descriptor_t *instance)
     125/*----------------------------------------------------------------------------*/
     126/** Helper function for parsing value of toggle bit.
     127 *
     128 * @param[in] instance TD structure to use.
     129 * @return Toggle bit value.
     130 */
     131static inline int td_toggle(td_t *instance)
     132{
     133        assert(instance);
     134        return (instance->device & TD_DEVICE_DATA_TOGGLE_ONE_FLAG) ? 1 : 0;
     135}
     136/*----------------------------------------------------------------------------*/
     137/** Helper function for parsing value of active bit
     138 *
     139 * @param[in] instance TD structure to use.
     140 * @return Active bit value.
     141 */
     142static inline bool td_is_active(td_t *instance)
    109143{
    110144        assert(instance);
    111145        return (instance->status & TD_STATUS_ERROR_ACTIVE) != 0;
    112146}
     147/*----------------------------------------------------------------------------*/
     148/** Helper function for setting IOC bit.
     149 *
     150 * @param[in] instance TD structure to use.
     151 */
     152static inline void td_set_ioc(td_t *instance)
     153{
     154        assert(instance);
     155        instance->status |= TD_STATUS_IOC_FLAG;
     156}
     157/*----------------------------------------------------------------------------*/
    113158#endif
    114159/**
Note: See TracChangeset for help on using the changeset viewer.