source: mainline/uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h@ eae83aa

lfn serial ticket/834-toolchain-update topic/fix-logger-deadlock topic/msim-upgrade topic/simplify-dev-export
Last change on this file since eae83aa was eae83aa, checked in by Jan Vesely <jano.vesely@…>, 15 years ago

Use SPD on IN packets, use proper PID type

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Copyright (c) 2010 Jan Vesely
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28/** @addtogroup usb
29 * @{
30 */
31/** @file
32 * @brief UHCI driver
33 */
34#ifndef DRV_UHCI_TRANSFER_DESCRIPTOR_H
35#define DRV_UHCI_TRANSFER_DESCRIPTOR_H
36
37#include <mem.h>
38#include <usb/usb.h>
39
40#include "link_pointer.h"
41
42/** UHCI Transfer Descriptor */
43typedef struct transfer_descriptor {
44 link_pointer_t next;
45
46 volatile uint32_t status;
47
48#define TD_STATUS_RESERVED_MASK 0xc000f800
49#define TD_STATUS_SPD_FLAG ( 1 << 29 )
50#define TD_STATUS_ERROR_COUNT_POS ( 27 )
51#define TD_STATUS_ERROR_COUNT_MASK ( 0x3 )
52#define TD_STATUS_ERROR_COUNT_DEFAULT 3
53#define TD_STATUS_LOW_SPEED_FLAG ( 1 << 26 )
54#define TD_STATUS_ISOCHRONOUS_FLAG ( 1 << 25 )
55#define TD_STATUS_COMPLETE_INTERRUPT_FLAG ( 1 << 24 )
56
57#define TD_STATUS_ERROR_ACTIVE ( 1 << 23 )
58#define TD_STATUS_ERROR_STALLED ( 1 << 22 )
59#define TD_STATUS_ERROR_BUFFER ( 1 << 21 )
60#define TD_STATUS_ERROR_BABBLE ( 1 << 20 )
61#define TD_STATUS_ERROR_NAK ( 1 << 19 )
62#define TD_STATUS_ERROR_CRC ( 1 << 18 )
63#define TD_STATUS_ERROR_BIT_STUFF ( 1 << 17 )
64#define TD_STATUS_ERROR_RESERVED ( 1 << 16 )
65#define TD_STATUS_ERROR_POS 16
66#define TD_STATUS_ERROR_MASK ( 0xff )
67
68#define TD_STATUS_ACTLEN_POS 0
69#define TD_STATUS_ACTLEN_MASK 0x7ff
70
71 volatile uint32_t device;
72
73#define TD_DEVICE_MAXLEN_POS 21
74#define TD_DEVICE_MAXLEN_MASK ( 0x7ff )
75#define TD_DEVICE_RESERVED_FLAG ( 1 << 20 )
76#define TD_DEVICE_DATA_TOGGLE_ONE_FLAG ( 1 << 19 )
77#define TD_DEVICE_ENDPOINT_POS 15
78#define TD_DEVICE_ENDPOINT_MASK ( 0xf )
79#define TD_DEVICE_ADDRESS_POS 8
80#define TD_DEVICE_ADDRESS_MASK ( 0x7f )
81#define TD_DEVICE_PID_POS 0
82#define TD_DEVICE_PID_MASK ( 0xff )
83
84 volatile uint32_t buffer_ptr;
85
86 /* 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
89 */
90} __attribute__((packed)) td_t;
91
92
93void td_init(td_t *instance, int error_count, size_t size, bool toggle, bool iso,
94 bool low_speed, usb_target_t target, usb_packet_id pid, void *buffer,
95 td_t *next);
96
97int td_status(td_t *instance);
98
99static inline size_t td_act_size(td_t *instance)
100{
101 assert(instance);
102 return
103 ((instance->status >> TD_STATUS_ACTLEN_POS) + 1)
104 & TD_STATUS_ACTLEN_MASK;
105}
106
107static inline bool td_is_short(td_t *instance)
108{
109 const size_t act_size = td_act_size(instance);
110 const size_t max_size =
111 ((instance->device >> TD_DEVICE_MAXLEN_POS) + 1)
112 & TD_DEVICE_MAXLEN_MASK;
113 return
114 (instance->status | TD_STATUS_SPD_FLAG) && act_size < max_size;
115}
116
117static inline bool td_is_active(td_t *instance)
118{
119 assert(instance);
120 return (instance->status & TD_STATUS_ERROR_ACTIVE) != 0;
121}
122#endif
123/**
124 * @}
125 */
Note: See TracBrowser for help on using the repository browser.