Ignore:
Timestamp:
2011-04-17T19:17:55Z (14 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63517c2, cfbbe1d3
Parents:
ef354b6 (diff), 8595577b (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:

new report structure fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/hw_struct/transfer_descriptor.h

    ref354b6 re50cd7f  
    3535#define DRV_OHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
    3636
     37#include <bool.h>
    3738#include <stdint.h>
     39#include "utils/malloc32.h"
    3840
    3941#include "completion_codes.h"
     42
     43/* OHCI TDs can handle up to 8KB buffers */
     44#define OHCI_TD_MAX_TRANSFER (8 * 1024)
    4045
    4146typedef struct td {
     
    4550#define TD_STATUS_DP_SHIFT (19)
    4651#define TD_STATUS_DP_SETUP (0x0)
    47 #define TD_STATUS_DP_IN (0x1)
    48 #define TD_STATUS_DP_OUT (0x2)
     52#define TD_STATUS_DP_OUT (0x1)
     53#define TD_STATUS_DP_IN (0x2)
    4954#define TD_STATUS_DI_MASK (0x7) /* delay interrupt, wait DI frames before int */
    5055#define TD_STATUS_DI_SHIFT (21)
     
    5257#define TD_STATUS_T_MASK (0x3)  /* data toggle 1x = use ED toggle carry */
    5358#define TD_STATUS_T_SHIFT (24)
     59#define TD_STATUS_T_0 (0x2)
     60#define TD_STATUS_T_1 (0x3)
     61#define TD_STATUS_T_ED (0)
    5462#define TD_STATUS_EC_MASK (0x3) /* error count */
    5563#define TD_STATUS_EC_SHIFT (26)
     
    6472        volatile uint32_t be; /* buffer end, address of the last byte */
    6573} __attribute__((packed)) td_t;
     74
     75void td_init(
     76    td_t *instance, usb_direction_t dir, void *buffer, size_t size, int toggle);
     77
     78inline static void td_set_next(td_t *instance, td_t *next)
     79{
     80        assert(instance);
     81        instance->next = addr_to_phys(next) & TD_NEXT_PTR_MASK;
     82}
     83
     84inline static bool td_is_finished(td_t *instance)
     85{
     86        assert(instance);
     87        int cc = (instance->status >> TD_STATUS_CC_SHIFT) & TD_STATUS_CC_MASK;
     88        /* something went wrong, error code is set */
     89        if (cc != CC_NOACCESS1 && cc != CC_NOACCESS2) {
     90                return true;
     91        }
     92        /* everything done */
     93        if (cc == CC_NOERROR && instance->cbp == 0) {
     94                return true;
     95        }
     96        return false;
     97}
     98
     99static inline int td_error(td_t *instance)
     100{
     101        assert(instance);
     102        int cc = (instance->status >> TD_STATUS_CC_SHIFT) & TD_STATUS_CC_MASK;
     103        return cc_to_rc(cc);
     104}
     105
     106static inline size_t td_remain_size(td_t *instance)
     107{
     108        assert(instance);
     109        if (instance->cbp == 0)
     110                return 0;
     111        return instance->be - instance->cbp + 1;
     112}
    66113#endif
    67114/**
Note: See TracChangeset for help on using the changeset viewer.