Ignore:
File:
1 edited

Legend:

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

    rfc9f88d rad86349  
    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.