1 |
27 |
unneback |
//=================================================================
|
2 |
|
|
//
|
3 |
|
|
// protocol.h
|
4 |
|
|
//
|
5 |
|
|
// USB testing - host<->target protocol
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
16 |
|
|
//
|
17 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
18 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
// for more details.
|
21 |
|
|
//
|
22 |
|
|
// You should have received a copy of the GNU General Public License along
|
23 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
25 |
|
|
//
|
26 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
27 |
|
|
// or inline functions from this file, or you compile this file and link it
|
28 |
|
|
// with other works to produce a work based on this file, this file does not
|
29 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
30 |
|
|
// License. However the source code for this file must still be made available
|
31 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
32 |
|
|
//
|
33 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
34 |
|
|
// this file might be covered by the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
37 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
38 |
|
|
// -------------------------------------------
|
39 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
40 |
|
|
//==========================================================================
|
41 |
|
|
//#####DESCRIPTIONBEGIN####
|
42 |
|
|
//
|
43 |
|
|
// This header file is shared between target and host, and serves to
|
44 |
|
|
// define certain aspects of the protocol used between the two such
|
45 |
|
|
// as request codes.
|
46 |
|
|
//
|
47 |
|
|
// Author(s): bartv
|
48 |
|
|
// Date: 2001-07-04
|
49 |
|
|
//####DESCRIPTIONEND####
|
50 |
|
|
//==========================================================================
|
51 |
|
|
|
52 |
|
|
// The largest control packet that will be sent or expected.
|
53 |
|
|
#define USBTEST_MAX_CONTROL_DATA 255
|
54 |
|
|
|
55 |
|
|
// The largest error message that can be sent.
|
56 |
|
|
#define USBTEST_MAX_MESSAGE 254
|
57 |
|
|
|
58 |
|
|
// The largest bulk transfer that will be sent or expected. Because of
|
59 |
|
|
// the use of the USB devfs support in the Linux kernel this is
|
60 |
|
|
// currently limited to a single page, i.e. 4096 bytes. To allow for
|
61 |
|
|
// padding, it is actually reduced to a slightly smaller size of 4090
|
62 |
|
|
// bytes. This should still be sufficient to test most interesting
|
63 |
|
|
// boundary conditions, apart from the transition to >64K.
|
64 |
|
|
//
|
65 |
|
|
// A small amount of additional buffer space should be allocated by
|
66 |
|
|
// both host and target to allow for padding and possibly cache
|
67 |
|
|
// alignment. All other protocols involve smaller transfers than this,
|
68 |
|
|
// <= 64 bytes for interrupt transfers, <= 1023 for isochronous.
|
69 |
|
|
#define USBTEST_MAX_BULK_DATA (4096)
|
70 |
|
|
#define USBTEST_MAX_BULK_DATA_EXTRA 1024
|
71 |
|
|
|
72 |
|
|
// The maximum number of tests that can be run concurrently. Each
|
73 |
|
|
// needs a separate thread, stack, and buffer so there are memory
|
74 |
|
|
// consumption implications.
|
75 |
|
|
#define USBTEST_MAX_CONCURRENT_TESTS 8
|
76 |
|
|
|
77 |
|
|
// Allow the host to find out the number of endpoints supported on
|
78 |
|
|
// this target. The theoretical maximum number of endpoints is 91
|
79 |
|
|
// (endpoint 0 control, endpoint 1-15 for both IN and OUT bulk, iso
|
80 |
|
|
// and interrupt) so a single byte response will suffice. The value
|
81 |
|
|
// and index fields are not used.
|
82 |
|
|
#define USBTEST_MAX_ENDPOINTS 91
|
83 |
|
|
#define USBTEST_ENDPOINT_COUNT 0x001
|
84 |
|
|
|
85 |
|
|
// Get hold of additional information about a specific entry in the
|
86 |
|
|
// array of endpoint details. The index field in the request
|
87 |
|
|
// identifies the entry of interest. The reply information is as per
|
88 |
|
|
// the usbs_testing_endpoint structure, and consists of:
|
89 |
|
|
// 1) one byte, the endpoint type (control, bulk, ...)
|
90 |
|
|
// 2) one byte, the endpoint number (as opposed to the array index number)
|
91 |
|
|
// 3) one byte for direction, USB_DIR_IN or USB_DIR_OUT
|
92 |
|
|
// 4) one byte for max_in_padding, usually 0
|
93 |
|
|
// 5) four bytes for min_size, 32-bit little-endian integer
|
94 |
|
|
// 6) four bytes for max_size, 32-bit little-endian integer
|
95 |
|
|
// 7) an additional n bytes for the devtab name, max ~240 bytes
|
96 |
|
|
// although usually far less.
|
97 |
|
|
#define USBTEST_ENDPOINT_DETAILS 0x002
|
98 |
|
|
|
99 |
|
|
// Report pass or failure. The host will send a string of up to
|
100 |
|
|
// MAX_CONTROL_DATA bytes. The value and index fields are not used.
|
101 |
|
|
#define USBTEST_PASS 0x003
|
102 |
|
|
#define USBTEST_PASS_EXIT 0x004
|
103 |
|
|
#define USBTEST_FAIL 0x005
|
104 |
|
|
#define USBTEST_FAIL_EXIT 0x006
|
105 |
|
|
|
106 |
|
|
// Synchronise. One problem with the current eCos USB API is that
|
107 |
|
|
// there is no way to have a delayed response to a control message.
|
108 |
|
|
// Any such support would be tricky, there are significant differences
|
109 |
|
|
// in the hardware implementations and also timing constraints that
|
110 |
|
|
// need to be satisfied. Instead the entire response to any control
|
111 |
|
|
// request has to be prepared at DSR level. Usually this does not
|
112 |
|
|
// cause any problems, e.g. for handling the standard control
|
113 |
|
|
// messages, but for USB testing it may not be possible to handle a
|
114 |
|
|
// request entirely at DSR level - yet the next full request should
|
115 |
|
|
// not come in until the current one has been handled at thread-level.
|
116 |
|
|
// To work around this there is support for a synchronization control
|
117 |
|
|
// message. The return value is a single byte, 1 if the target is
|
118 |
|
|
// ready for new requests, 0 if there is a still a request being
|
119 |
|
|
// processed. The host can then perform some polling.
|
120 |
|
|
#define USBTEST_SYNCH 0x007
|
121 |
|
|
|
122 |
|
|
// Abort. There is no easy way to get both host and target back to a
|
123 |
|
|
// known state, so abort the current test run.
|
124 |
|
|
#define USBTEST_ABORT 0x008
|
125 |
|
|
|
126 |
|
|
// Cancel the current batch of tests. Something has gone wrong at the
|
127 |
|
|
// Tcl level, so any tests already prepared must be abandoned. No
|
128 |
|
|
// additional data is required.
|
129 |
|
|
#define USBTEST_CANCEL 0x009
|
130 |
|
|
|
131 |
|
|
// Start the current batch of tests. No additional data is involved
|
132 |
|
|
// or expected.
|
133 |
|
|
#define USBTEST_START 0x00A
|
134 |
|
|
|
135 |
|
|
// Has the current batch of tests finished? The host side polls the
|
136 |
|
|
// target at regular intervals for this information.
|
137 |
|
|
#define USBTEST_FINISHED 0x00B
|
138 |
|
|
|
139 |
|
|
// Set the test-terminated flag. Something has gone wrong, probably a
|
140 |
|
|
// timeout.
|
141 |
|
|
#define USBTEST_SET_TERMINATED 0x00C
|
142 |
|
|
|
143 |
|
|
// Get hold of recovery information for thread i in the target, where
|
144 |
|
|
// the index field of the request identifies the thread. The result
|
145 |
|
|
// is zero-bytes if the specified test has already finished, otherwise
|
146 |
|
|
// a recovery structure.
|
147 |
|
|
#define USBTEST_GET_RECOVERY 0x00D
|
148 |
|
|
|
149 |
|
|
// The target should perform a recovery action to unlock a thread
|
150 |
|
|
// on the host. The request holds a recovery structure.
|
151 |
|
|
#define USBTEST_PERFORM_RECOVERY 0x00E
|
152 |
|
|
|
153 |
|
|
// Collect the test result. The result is a single byte that indicates
|
154 |
|
|
// pass or fail, optionally followed by a failure message.
|
155 |
|
|
#define USBTEST_GET_RESULT 0x00F
|
156 |
|
|
|
157 |
|
|
// The current batch of tests has completed. Perform any final clean-ups.
|
158 |
|
|
#define USBTEST_BATCH_DONE 0x010
|
159 |
|
|
|
160 |
|
|
// Set the verbosity level on the target-side
|
161 |
|
|
#define USBTEST_VERBOSE 0x011
|
162 |
|
|
|
163 |
|
|
// Perform endpoint initialization to ensure host and target
|
164 |
|
|
// can actually communicate over a given endpoint
|
165 |
|
|
#define USBTEST_INIT_CONTROL 0x012
|
166 |
|
|
#define USBTEST_INIT_BULK_IN 0x013
|
167 |
|
|
#define USBTEST_INIT_BULK_OUT 0x014
|
168 |
|
|
#define USBTEST_INIT_ISO_IN 0x015
|
169 |
|
|
#define USBTEST_INIT_ISO_OUT 0x016
|
170 |
|
|
#define USBTEST_INIT_INTERRUPT_IN 0x017
|
171 |
|
|
#define USBTEST_INIT_INTERRUPT_OUT 0x018
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
// A standard bulk test. The data consists of a UsbTest_Bulk
|
175 |
|
|
// structure, suitably packed.
|
176 |
|
|
#define USBTEST_TEST_BULK 0x040
|
177 |
|
|
|
178 |
|
|
// A control-IN test. The host will send reserved control messages with
|
179 |
|
|
// an appropriate length field, and the target should return that data.
|
180 |
|
|
#define USBTEST_TEST_CONTROL_IN 0x041
|
181 |
|
|
|
182 |
|
|
// Sub-protocols for reserved control messages, supporting test operations
|
183 |
|
|
// other than control-IN.
|
184 |
|
|
#define USBTEST_RESERVED_CONTROL_IN 0x01
|
185 |
|
|
|
186 |
|
|
// Work around a problem with control messages that involve additional
|
187 |
|
|
// data from host to target. This problem is not yet well-understood.
|
188 |
|
|
// The workaround involves sending multiple control packets with
|
189 |
|
|
// up to four bytes encoded in the index and value fields.
|
190 |
|
|
#define USBTEST_CONTROL_DATA1 0x0F1
|
191 |
|
|
#define USBTEST_CONTROL_DATA2 0x0F2
|
192 |
|
|
#define USBTEST_CONTROL_DATA3 0x0F3
|
193 |
|
|
#define USBTEST_CONTROL_DATA4 0x0F4
|
194 |
|
|
|