Ignore:
Timestamp:
2011-01-25T18:58:08Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7977fa1
Parents:
bae9e76
Message:

Transfer descriptor flags and masks

File:
1 edited

Legend:

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

    rbae9e76 rd5f7a8ab  
    3737#include <mem.h>
    3838#include <usb/usb.h>
     39
    3940#include "callback.h"
    40 
    41 /** Status field in UHCI Transfer Descriptor (TD) */
    42 typedef struct status {
    43         uint8_t active:1;
    44         uint8_t stalled:1;
    45         uint8_t data_buffer_error:1;
    46         uint8_t babble:1;
    47         uint8_t nak:1;
    48         uint8_t crc:1;
    49         uint8_t bitstuff:1;
    50         uint8_t :1; /* reserved */
    51 } status_t;
     41#include "link_pointer.h"
    5242
    5343/** UHCI Transfer Descriptor */
    5444typedef struct transfer_descriptor {
    55         uint32_t fpl:28;
    56         char :1; /* reserved */
    57         uint8_t depth:1;
    58         uint8_t qh:1;
    59         uint8_t terminate:1;
     45        link_pointer_t next;
    6046
    61         char :2; /* reserved */
    62         uint8_t spd:1;
    63         uint8_t error_count:2;
    64         uint8_t low_speed:1;
    65         uint8_t isochronous:1;
    66         uint8_t ioc:1;
    67         status_t status;
    68         char :5; /* reserved */
    69         uint16_t act_len:10;
     47        uint32_t status;
    7048
    71         uint16_t maxlen:11;
    72         char :1; /* reserved */
    73         uint8_t toggle:1;
    74         uint8_t endpoint:4;
    75         uint8_t address:7;
    76         uint8_t pid;
     49#define TD_STATUS_RESERVED_MASK 0xc000f800
     50#define TD_STATUS_SPD_FLAG ( 1 << 29 )
     51#define TD_STATUS_ERROR_COUNT_POS ( 27 )
     52#define TD_STATUS_ERROR_COUNT_MASK ( 0x11 )
     53#define TD_STATUS_ERROR_COUNT_DEFAULT 3
     54#define TD_STATUS_LOW_SPEED_FLAG ( 1 << 26 )
     55#define TD_STATUS_ISOCHRONOUS_FLAG ( 1 << 25 )
     56#define TD_STATUS_COMPLETE_INTERRUPT_FLAG ( 1 << 24 )
     57
     58#define TD_STATUS_ACTIVE ( 1 << 23 )
     59#define TD_STATUS_ERROR_STALLED ( 1 << 22 )
     60#define TD_STATUS_ERROR_BUFFER ( 1 << 21 )
     61#define TD_STATUS_ERROR_BABBLE ( 1 << 20 )
     62#define TD_STATUS_ERROR_NAK ( 1 << 19 )
     63#define TD_STATUS_ERROR_CRC ( 1 << 18 )
     64#define TD_STATUS_ERROR_BIT_STUFF ( 1 << 17 )
     65#define TD_STATUS_ERROR_RESERVED ( 1 << 16 )
     66#define TD_STATUS_POS 16
     67#define TD_STATUS_MASK ( 0xff )
     68
     69#define TD_STATUS_ACTLEN_POS 0
     70#define TD_STATUS_ACTLEN_MASK 0x7ff
     71
     72        uint32_t device;
     73
     74#define TD_DEVICE_MAXLEN_POS 21
     75#define TD_DEVICE_MAXLEN_MASK ( 0x7ff )
     76#define TD_DEVICE_RESERVED_FLAG ( 1 << 20 )
     77#define TD_DEVICE_DATA_TOGGLE_ONE_FLAG ( 1 << 19 )
     78#define TD_DEVICE_ENDPOINT_POS 15
     79#define TD_DEVICE_ENDPOINT_MASK ( 0xf )
     80#define TD_DEVICE_ADDRESS_POS 8
     81#define TD_DEVICE_ADDRESS_MASK ( 0x7f )
     82#define TD_DEVICE_PID_POS 0
     83#define TD_DEVICE_PID_MASK ( 0xff )
    7784
    7885        uint32_t buffer_ptr;
     
    8390         * on 32bits systems.
    8491         */
    85         struct transfer_descriptor *next;
     92        struct transfer_descriptor *next_va;
    8693        callback_t *callback;
    8794} __attribute__((packed)) transfer_descriptor_t;
     
    9299{
    93100        assert(instance);
    94         bzero(instance, sizeof(transfer_descriptor_t));
    95101
    96         instance->depth = 1;
    97         instance->terminate = 1;
    98 
    99         assert(error_count < 4);
    100         instance->error_count = error_count;
    101         instance->status.active = 1;
     102        instance->next =
     103          0 | LINK_POINTER_VERTICAL_FLAG | LINK_POINTER_TERMINATE_FLAG;
    102104
    103105        assert(size < 1024);
    104         instance->maxlen = size;
     106        instance->status = 0
     107          | ((error_count & TD_STATUS_ERROR_COUNT_MASK) << TD_STATUS_ERROR_COUNT_POS)
     108          | TD_STATUS_ACTIVE;
    105109
    106         instance->address = target.address;
    107         instance->endpoint = target.endpoint;
     110        instance->device = 0
     111                | ((size & TD_DEVICE_MAXLEN_MASK) << TD_DEVICE_MAXLEN_POS)
     112                | ((target.address & TD_DEVICE_ADDRESS_MASK) << TD_DEVICE_ADDRESS_POS)
     113                | ((target.endpoint & TD_DEVICE_ENDPOINT_MASK) << TD_DEVICE_ENDPOINT_POS)
     114                | ((pid & TD_DEVICE_PID_MASK) << TD_DEVICE_PID_POS);
    108115
    109         instance->pid = pid;
     116        instance->next_va = NULL;
     117        instance->callback = NULL;
    110118
    111119        return EOK;
Note: See TracChangeset for help on using the changeset viewer.