1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// usbs_d12_data.cxx
|
4 |
|
|
//
|
5 |
|
|
// Static data for the D12 USB device driver
|
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, 2006 Free Software Foundation, 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
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//==========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): fmp
|
43 |
|
|
// Contributors: fmp
|
44 |
|
|
// Date: 2004-05-27
|
45 |
|
|
//
|
46 |
|
|
// This file contains various objects that should go into extras.o
|
47 |
|
|
// rather than libtarget.a, e.g. devtab entries that would normally
|
48 |
|
|
// be eliminated by the selective linking.
|
49 |
|
|
//
|
50 |
|
|
//####DESCRIPTIONEND####
|
51 |
|
|
//==========================================================================
|
52 |
|
|
|
53 |
|
|
#include <cyg/io/devtab.h>
|
54 |
|
|
#include <cyg/io/usb/usbs_d12.h>
|
55 |
|
|
#include <pkgconf/devs_usb_d12.h>
|
56 |
|
|
|
57 |
|
|
// ----------------------------------------------------------------------------
|
58 |
|
|
// Initialization. The goal here is to call usbs_d12_init()
|
59 |
|
|
// early on during system startup, to take care of things like
|
60 |
|
|
// registering interrupt handlers etc. which are best done
|
61 |
|
|
// during system init.
|
62 |
|
|
//
|
63 |
|
|
// If the endpoint 0 devtab entry is available then its init()
|
64 |
|
|
// function can be used to take care of this. However the devtab
|
65 |
|
|
// entries are optional so an alternative mechanism must be
|
66 |
|
|
// provided. Unfortunately although it is possible to give
|
67 |
|
|
// a C function the constructor attribute, it cannot be given
|
68 |
|
|
// an initpri attribute. Instead it is necessary to define a
|
69 |
|
|
// dummy C++ class.
|
70 |
|
|
|
71 |
|
|
extern "C" void usbs_d12_init(void);
|
72 |
|
|
|
73 |
|
|
#ifndef CYGVAR_DEVS_USB_D12_EP0_DEVTAB_ENTRY
|
74 |
|
|
class usbs_d12_initialization {
|
75 |
|
|
public:
|
76 |
|
|
usbs_d12_initialization() {
|
77 |
|
|
usbs_d12_init();
|
78 |
|
|
}
|
79 |
|
|
};
|
80 |
|
|
|
81 |
|
|
static usbs_d12_initialization usbs_d12_init_object
|
82 |
|
|
CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_IO);
|
83 |
|
|
#endif
|
84 |
|
|
|
85 |
|
|
// ----------------------------------------------------------------------------
|
86 |
|
|
// The devtab entries. Each of these is optional, many applications
|
87 |
|
|
// will want to use the lower-level API rather than go via
|
88 |
|
|
// open/read/write/ioctl.
|
89 |
|
|
|
90 |
|
|
#ifdef CYGVAR_DEVS_USB_D12_EP0_DEVTAB_ENTRY
|
91 |
|
|
|
92 |
|
|
// For endpoint 0 the only legal operations are get_config() and
|
93 |
|
|
// set_config(), and these are provided by the common package.
|
94 |
|
|
|
95 |
|
|
static bool
|
96 |
|
|
usbs_d12_devtab_ep0_init(struct cyg_devtab_entry* tab)
|
97 |
|
|
{
|
98 |
|
|
CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
|
99 |
|
|
usbs_d12_init();
|
100 |
|
|
return true;
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
static
|
104 |
|
|
CHAR_DEVIO_TABLE(usbs_d12_ep0_devtab_functions,
|
105 |
|
|
&cyg_devio_cwrite,
|
106 |
|
|
&cyg_devio_cread,
|
107 |
|
|
&cyg_devio_select,
|
108 |
|
|
&usbs_devtab_get_config,
|
109 |
|
|
&usbs_devtab_set_config);
|
110 |
|
|
|
111 |
|
|
static CHAR_DEVTAB_ENTRY(usbs_d12_ep0_devtab_entry,
|
112 |
|
|
CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "0c",
|
113 |
|
|
0,
|
114 |
|
|
&usbs_d12_ep0_devtab_functions,
|
115 |
|
|
&usbs_d12_devtab_ep0_init,
|
116 |
|
|
0,
|
117 |
|
|
(void*) &usbs_d12_ep0);
|
118 |
|
|
#endif
|
119 |
|
|
|
120 |
|
|
// ----------------------------------------------------------------------------
|
121 |
|
|
// Common routines for ep1 and ep2.
|
122 |
|
|
|
123 |
|
|
#if defined(CYGVAR_DEVS_USB_D12_TX_EP1_DEVTAB_ENTRY) || \
|
124 |
|
|
defined(CYGVAR_DEVS_USB_D12_RX_EP1_DEVTAB_ENTRY) || \
|
125 |
|
|
defined(CYGVAR_DEVS_USB_D12_TX_EP2_DEVTAB_ENTRY) || \
|
126 |
|
|
defined(CYGVAR_DEVS_USB_D12_RX_EP2_DEVTAB_ENTRY)
|
127 |
|
|
|
128 |
|
|
static bool
|
129 |
|
|
usbs_d12_devtab_dummy_init(struct cyg_devtab_entry* tab)
|
130 |
|
|
{
|
131 |
|
|
CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
|
132 |
|
|
return true;
|
133 |
|
|
}
|
134 |
|
|
#endif
|
135 |
|
|
|
136 |
|
|
// ----------------------------------------------------------------------------
|
137 |
|
|
// tx (in) ep1 devtab entry. This can only be used for slave->host,
|
138 |
|
|
// so only the cwrite() function makes sense.
|
139 |
|
|
|
140 |
|
|
#ifdef CYGVAR_DEVS_USB_D12_TX_EP1_DEVTAB_ENTRY
|
141 |
|
|
|
142 |
|
|
static
|
143 |
|
|
CHAR_DEVIO_TABLE(usbs_d12_tx_ep1_devtab_functions,
|
144 |
|
|
&usbs_devtab_cwrite,
|
145 |
|
|
&cyg_devio_cread,
|
146 |
|
|
&cyg_devio_select,
|
147 |
|
|
&usbs_devtab_get_config,
|
148 |
|
|
&usbs_devtab_set_config);
|
149 |
|
|
|
150 |
|
|
static
|
151 |
|
|
CHAR_DEVTAB_ENTRY(usbs_d12_tx_ep1_devtab_entry,
|
152 |
|
|
CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "1w",
|
153 |
|
|
0,
|
154 |
|
|
&usbs_d12_tx_ep1_devtab_functions,
|
155 |
|
|
&usbs_d12_devtab_dummy_init,
|
156 |
|
|
0,
|
157 |
|
|
(void*) &usbs_d12_tx_ep1);
|
158 |
|
|
#endif
|
159 |
|
|
|
160 |
|
|
// ----------------------------------------------------------------------------
|
161 |
|
|
// rx (out) ep1 devtab entry. This can only be used for host->slave,
|
162 |
|
|
// so only the cread() function makes sense.
|
163 |
|
|
|
164 |
|
|
#ifdef CYGVAR_DEVS_USB_D12_RX_EP1_DEVTAB_ENTRY
|
165 |
|
|
|
166 |
|
|
static
|
167 |
|
|
CHAR_DEVIO_TABLE(usbs_d12_rx_ep1_devtab_functions,
|
168 |
|
|
&cyg_devio_cwrite,
|
169 |
|
|
&usbs_devtab_cread,
|
170 |
|
|
&cyg_devio_select,
|
171 |
|
|
&usbs_devtab_get_config,
|
172 |
|
|
&usbs_devtab_set_config);
|
173 |
|
|
|
174 |
|
|
static
|
175 |
|
|
CHAR_DEVTAB_ENTRY(usbs_d12_rx_ep1_devtab_entry,
|
176 |
|
|
CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "1r",
|
177 |
|
|
0,
|
178 |
|
|
&usbs_d12_rx_ep1_devtab_functions,
|
179 |
|
|
&usbs_d12_devtab_dummy_init,
|
180 |
|
|
0,
|
181 |
|
|
(void*) &usbs_d12_rx_ep1);
|
182 |
|
|
#endif
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
// ----------------------------------------------------------------------------
|
186 |
|
|
// tx (in) ep2 devtab entry. This can only be used for slave->host, so only the
|
187 |
|
|
// cwrite() function makes sense.
|
188 |
|
|
|
189 |
|
|
#ifdef CYGVAR_DEVS_USB_D12_TX_EP2_DEVTAB_ENTRY
|
190 |
|
|
|
191 |
|
|
static
|
192 |
|
|
CHAR_DEVIO_TABLE(usbs_d12_tx_ep2_devtab_functions,
|
193 |
|
|
&usbs_devtab_cwrite,
|
194 |
|
|
&cyg_devio_cread,
|
195 |
|
|
&cyg_devio_select,
|
196 |
|
|
&usbs_devtab_get_config,
|
197 |
|
|
&usbs_devtab_set_config);
|
198 |
|
|
|
199 |
|
|
static
|
200 |
|
|
CHAR_DEVTAB_ENTRY(usbs_d12_tx_ep2_devtab_entry,
|
201 |
|
|
CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "2w",
|
202 |
|
|
0,
|
203 |
|
|
&usbs_d12_tx_ep2_devtab_functions,
|
204 |
|
|
&usbs_d12_devtab_dummy_init,
|
205 |
|
|
0,
|
206 |
|
|
(void*) &usbs_d12_tx_ep2);
|
207 |
|
|
#endif
|
208 |
|
|
|
209 |
|
|
// ----------------------------------------------------------------------------
|
210 |
|
|
// rx (out) ep2 devtab entry. This can only be used for host->slave,
|
211 |
|
|
// so only the cread() function makes sense.
|
212 |
|
|
|
213 |
|
|
#ifdef CYGVAR_DEVS_USB_D12_RX_EP2_DEVTAB_ENTRY
|
214 |
|
|
|
215 |
|
|
static
|
216 |
|
|
CHAR_DEVIO_TABLE(usbs_d12_rx_ep2_devtab_functions,
|
217 |
|
|
&cyg_devio_cwrite,
|
218 |
|
|
&usbs_devtab_cread,
|
219 |
|
|
&cyg_devio_select,
|
220 |
|
|
&usbs_devtab_get_config,
|
221 |
|
|
&usbs_devtab_set_config);
|
222 |
|
|
|
223 |
|
|
static
|
224 |
|
|
CHAR_DEVTAB_ENTRY(usbs_d12_rx_ep2_devtab_entry,
|
225 |
|
|
CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "2r",
|
226 |
|
|
0,
|
227 |
|
|
&usbs_d12_rx_ep2_devtab_functions,
|
228 |
|
|
&usbs_d12_devtab_dummy_init,
|
229 |
|
|
0,
|
230 |
|
|
(void*) &usbs_d12_rx_ep2);
|
231 |
|
|
#endif
|