AM261x MCU+ SDK: os_defs.h Source File

| AM261x MCU+ SDK 26.00.00 |

os_defs.h
Go to the documentation of this file.
1 #ifndef _DWC_NO_OS_DEFS_H_
2 #define _DWC_NO_OS_DEFS_H_
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
15 #undef linux
16 #undef __linux
17 #undef __linux__
18
19 #include <stdint.h>
20 #include <stddef.h>
21 #include <stdarg.h>
22 #include <string.h> // for memcpy
23 #include <stdbool.h>
24 #include <stdio.h>
25
26 /* HACK fixes */
27 #define NEAR
28 #ifndef TRUE
29 #define TRUE 1
30 #endif
31 #ifndef FALSE
32 #define FALSE 0
33 #endif
34
35
39 typedef unsigned long long u64;
40 //typedef unsigned long long u_int64_t;
41 typedef unsigned int u32;
42 //typedef unsigned int u_int32_t;
43 typedef unsigned short u16;
44 //typedef unsigned short u_int16_t;
45 typedef unsigned char u8;
46 //typedef unsigned char u_int8_t;
47 typedef unsigned char UINT8;
48
49 typedef long long s64;
50 typedef int s32;
51 typedef short s16;
52 typedef char s8;
53
54 typedef unsigned long u_long;
55 typedef unsigned int u_int;
56 typedef unsigned short u_short;
57 typedef unsigned char u_char;
62 typedef unsigned long dwc_dma_t;
63 #define DWC_DMA_ADDR_INVALID (~(dwc_dma_t)0)
64
67 //#define UPACKED __attribute__((__packed__))
68 #define UPACKED
69
71 #define UALIGNED16 __attribute__((__aligned__(16)))
72
74 #define __iomem /* */
75
76 #define KERN_DEBUG "debug" /* debug messages */
77 #define KERN_INFO "info" /* informational messages */
78 #define KERN_WARNING "war" /* warning messages */
79 #define KERN_ERR "err" /* error messages */
80
81 // from /usr/include/asm-x86_64/errno.h
82 #define EIO 5 /* I/O error */
83 #define EAGAIN 11 /* Try again */
84 #define ENOMEM 12 /* Out of memory */
85 #define EBUSY 16 /* Device or resource busy */
86 #define ENODEV 19 /* No such device */
87 #define EINVAL 22 /* Invalid argument */
88 #define ENOSPC 28 /* No space left on device */
89 #define EPIPE 32 /* Broken pipe */
90 #define EDOM 33 /* Math argument out of domain of func */
91 #define ENODATA 61 /* No data available */
92 #define ENOSR 63 /* Out of streams resources */
93 #define ECOMM 70 /* Communication error on send */
94 #define EPROTO 71 /* Protocol error */
95 #define EOVERFLOW 75 /* Value too large for defined data type */
96 #define ERESTART 85 /* Interrupted system call should be restarted */
97 #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
98 #define ECONNABORTED 103 /* Software caused connection abort */
99 #define ECONNRESET 104 /* Connection reset by peer */
100 #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
101 #define ETIMEDOUT 110 /* Connection timed out */
102 #define EINPROGRESS 115 /* Operation now in progress */
103
105 #define wmb() do {} while ((bool)(0))
106
107 #define interrupt_disable() 0
108 #define interrupt_enable() do {} while ((bool)(0))
109
110 #define dwc_init_spinlock(d, p) do {} while ((bool)(0))
111 #define dwc_acquire_spinlock(d, p) do {} while ((bool)(0))
112 #define dwc_release_spinlock(d, p) do {} while ((bool)(0))
113 #define dwc_acquire_spinlock_irq(d, p, f) do { (f) = interrupt_disable(); } while ((bool)(0))
114 #define dwc_release_spinlock_irq(d, p, f) do { if (f > 0U) { interrupt_enable(); } } while ((bool)(0))
115
116 struct task_struct {
117 int dummy;
118 };
119
120 struct tasklet_struct {
121 int dummy;
122 };
123
124
125 #include "usb.h"
126 #include "dwc_list.h"
127
130 #define DWC_E_INVALID EINVAL
131 #define DWC_E_NO_MEMORY ENOMEM
132 #define DWC_E_NO_DEVICE ENODEV
133 #define DWC_E_NOT_SUPPORTED EOPNOTSUPP
134 #define DWC_E_TIMEOUT ETIMEDOUT
135 #define DWC_E_BUSY EBUSY
136 #define DWC_E_AGAIN EAGAIN
137 #define DWC_E_RESTART ERESTART
138 #define DWC_E_ABORT ECONNABORTED
139 #define DWC_E_SHUTDOWN ESHUTDOWN
140 #define DWC_E_NO_DATA ENODATA
141 #define DWC_E_DISCONNECT ECONNRESET
142 #define DWC_E_UNKNOWN EINVAL
143 #define DWC_E_NO_STREAM_RES ENOSR
144 #define DWC_E_COMMUNICATION ECOMM
145 #define DWC_E_OVERFLOW EOVERFLOW
146 #define DWC_E_PROTOCOL EPROTO
147 #define DWC_E_IN_PROGRESS EINPROGRESS
148 #define DWC_E_PIPE EPIPE
149 #define DWC_E_IO EIO
150 #define DWC_E_NO_SPACE ENOSPC
151 #define DWC_E_DOMAIN EDOM
152
159 #define DWC_NUM_BULK_TRBS 1
160 #define DWC_NUM_INTR_TRBS 1
161 #define DWC_NUM_ISOC_TRBS 32
162
168 typedef struct dwc_usb3_core_params {
169 int burst;
170 int newcore;
171 int phy;
172 int wakeup;
173 int pwrctl;
174 int lpmctl;
175 int phyctl;
176 int usb2mode;
177 int hibernate;
178 int hiberdisc;
179 int clkgatingen;
180 int ssdisquirk;
181 int nobos;
182 int loop;
183 int nump;
184 int newcsr;
185 int rxfsz;
186 int txfsz[16];
187 int txfsz_cnt;
188 int baseline_besl;
189 int deep_besl;
190 int besl;
191 } dwc_usb3_core_params_t;
192
193 // linux/usb/gadget.h
194
198 typedef struct usb_ept {
199 const void *desc;
200 const void *comp_desc;
201 unsigned maxpacket:16;
202 u8 address;
203 } usb_ep_t;
204
208 typedef struct usb_request {
209 void *buf;
210 unsigned length;
211 dwc_dma_t dma;
213 unsigned stream_id:16;
214 unsigned zero:1;
216 void (*complete)(usb_ep_t *ep, struct usb_request *req);
218 int status;
219 unsigned actual;
220 } usb_request_t;
221
224 static inline void dwc_usb3_task_schedule(struct tasklet_struct *tasklet)
225 {
226 #ifdef LINUXTEST
227 tasklet_schedule(tasklet);
228 #endif
229 }
230
231 /* Make the following structure type definitions "packed" if using a Microsoft
232 * compiler. The UPACKED attribute (defined above) embedded in the structure
233 * type definitions does the same thing for GCC. Other compilers may need
234 * something different.
235 */
236 #ifdef _MSC_VER
237 #include <pshpack1.h>
238 #endif
239
240
241 typedef struct usb_dfu_functional_descriptor_s {
242 uByte bLength; /* size of descriptor = 0x9 */
243 uByte bDescriptorType; /* DFU functional descriptor type. 0x21 */
244 uByte bmAttributes; /* DFU attributes */
245 uWord wDetachTimeOut; /* max time (ms) wait for reset after DFU_DETACH */
246 uWord wTransferSize; /* maximum number of bytes that device can accept
247 per control-write transaction */
248 uWord bcdDFUVersion;
249 } usb_dfu_functional_descriptor_t;
250
253 typedef struct fs_msc_config_desc_st {
254 usb_config_descriptor_t config_desc;
255 usb_interface_descriptor_t intf_desc;
256 usb_endpoint_descriptor_t bulk_in_ep_desc;
257 usb_endpoint_descriptor_t bulk_out_ep_desc;
258 } UPACKED fs_msc_config_desc_t;
259
260
263 typedef struct hs_msc_config_desc_st {
264 usb_config_descriptor_t config_desc;
265 usb_interface_descriptor_t intf_desc;
266 usb_endpoint_descriptor_t bulk_in_ep_desc; // only one IN bulk EP in the Launchpad example
267 usb_endpoint_descriptor_t bulk_out_ep_desc; // removed this
268 } UPACKED hs_msc_config_desc_t;
269
270 typedef struct hs_dfu_config_desc_st {
271 usb_config_descriptor_t config_desc;
272 usb_interface_descriptor_t intf_desc;
273 usb_interface_descriptor_t intf1_desc;
274 usb_dfu_functional_descriptor_t dfu_func_desc;
275 } UPACKED dfu_config_desc_t;
278 typedef struct ss_config_desc_st {
279 usb_config_descriptor_t config_desc;
280 usb_interface_descriptor_t intf_desc;
281 usb_endpoint_descriptor_t bulk_in_ep_desc;
282 ss_endpoint_companion_descriptor_t bulk_in_ss_ep_comp_desc;
283 usb_endpoint_descriptor_t bulk_out_ep_desc;
284 ss_endpoint_companion_descriptor_t bulk_out_ss_ep_comp_desc;
285 } UPACKED ss_config_desc_t;
286
287 /* Stop packing structure type definitions */
288 #ifdef _MSC_VER
289 #include <poppack.h>
290 #endif
291
292 /* These structures are defined in no_os_ep0.c */
293
294 #ifdef USB_BOOT_DFU
295 extern const dfu_config_desc_t dfu_config_desc;
296 #else
297 extern fs_msc_config_desc_t fs_msc_config_desc;
298 extern hs_msc_config_desc_t hs_msc_config_desc;
299 #endif
300
301 extern ss_config_desc_t ss_config_desc;
302
307 struct dwc_usb3_device; /* so the simulation code can include just this file */
308
309 extern const dwc_usb3_core_params_t usb3ss_module_params;
310
311 #ifndef LINUXTEST
312 extern struct dwc_usb3_device *dwc_usb3_driver_init(u32 base_addr_dwc);
313 extern void dwc_usb3_driver_remove(void);
314 extern void dwc_usb3_common_irq(int irq, void *dev);
315 #endif
316
317 extern usb_ep_t *dwc_usb3_ep_enable(struct dwc_usb3_device *usb3_dev, const void *epdesc,
318 const void *epcomp);
319 extern int dwc_usb3_ep_disable(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep);
320 extern int dwc_usb3_close_all_ep(struct dwc_usb3_device *usb3_dev);
321 extern usb_request_t *dwc_usb3_alloc_request(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep);
322 extern void dwc_usb3_free_request(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep,
323 usb_request_t *usb_req);
324 extern int dwc_usb3_ep_queue(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep,
325 usb_request_t *usb_req);
326 extern int dwc_usb3_ep_dequeue(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep,
327 usb_request_t *usb_req);
328 extern int dwc_usb3_wait_pme(struct dwc_usb3_device *usb3_dev);
329 extern int dwc_usb3_handle_pme_intr(struct dwc_usb3_device *usb3_dev);
330
331 extern int dwc_usb3_function_init(struct dwc_usb3_device *usb3_dev);
332 extern void dwc_usb3_function_remove(struct dwc_usb3_device *usb3_dev);
333 extern int dwc_usb3_function_connect(struct dwc_usb3_device *usb3_dev, int speed);
334 extern int dwc_usb3_function_disconnect(struct dwc_usb3_device *usb3_dev);
335
336 #ifdef __cplusplus
337 }
338 #endif
339
340 #endif /* _DWC_NO_OS_DEFS_H_ */
dwc_usb3_handle_pme_intr
int dwc_usb3_handle_pme_intr(struct dwc_usb3_device *usb3_dev)
task_struct
Definition: os_defs.h:116
u_int
unsigned int u_int
Definition: os_defs.h:55
fs_msc_config_desc
fs_msc_config_desc_t fs_msc_config_desc
hs_msc_config_desc
hs_msc_config_desc_t hs_msc_config_desc
u32
unsigned int u32
Definition: os_defs.h:41
ss_config_desc_t::bulk_in_ss_ep_comp_desc
ss_endpoint_companion_descriptor_t bulk_in_ss_ep_comp_desc
Definition: os_defs.h:282
dwc_usb3_core_params_t::pwrctl
int pwrctl
Definition: os_defs.h:173
ss_config_desc_t
Definition: os_defs.h:278
dwc_usb3_task_schedule
static void dwc_usb3_task_schedule(struct tasklet_struct *tasklet)
Definition: os_defs.h:224
usb_ep_t::maxpacket
unsigned maxpacket
Definition: os_defs.h:201
usb_ep_t::address
u8 address
Definition: os_defs.h:202
dwc_usb3_driver_init
struct dwc_usb3_device * dwc_usb3_driver_init(u32 base_addr_dwc)
u16
unsigned short u16
Definition: os_defs.h:43
hs_msc_config_desc_t::bulk_in_ep_desc
usb_endpoint_descriptor_t bulk_in_ep_desc
Definition: os_defs.h:266
usb_ep_t
Definition: os_defs.h:198
u_short
unsigned short u_short
Definition: os_defs.h:56
UPACKED
Definition: usb.h:103
dwc_usb3_core_params_t::txfsz_cnt
int txfsz_cnt
Definition: os_defs.h:187
usb_ep_t::comp_desc
const void * comp_desc
Definition: os_defs.h:200
dwc_usb3_ep_enable
usb_ep_t * dwc_usb3_ep_enable(struct dwc_usb3_device *usb3_dev, const void *epdesc, const void *epcomp)
Definition: no_os_gadget.c:502
dfu_config_desc_t::intf_desc
usb_interface_descriptor_t intf_desc
Definition: os_defs.h:272
hs_msc_config_desc_t::config_desc
usb_config_descriptor_t config_desc
Definition: os_defs.h:264
dfu_config_desc_t
Definition: os_defs.h:270
dwc_usb3_wait_pme
int dwc_usb3_wait_pme(struct dwc_usb3_device *usb3_dev)
ss_config_desc_t::intf_desc
usb_interface_descriptor_t intf_desc
Definition: os_defs.h:280
dwc_usb3_core_params_t::nump
int nump
Definition: os_defs.h:183
dwc_usb3_common_irq
void dwc_usb3_common_irq(int irq, void *dev)
usb_dfu_functional_descriptor_t::bDescriptorType
uByte bDescriptorType
Definition: os_defs.h:243
usb_request_t::zero
unsigned zero
Definition: os_defs.h:214
dwc_usb3_core_params_t::hiberdisc
int hiberdisc
Definition: os_defs.h:178
ss_config_desc_t::bulk_out_ep_desc
usb_endpoint_descriptor_t bulk_out_ep_desc
Definition: os_defs.h:283
usb_dfu_functional_descriptor_t
Definition: os_defs.h:241
dwc_usb3_core_params_t::ssdisquirk
int ssdisquirk
Definition: os_defs.h:180
ss_endpoint_companion_descriptor_t
Definition: usb.h:344
dwc_dma_t
unsigned long dwc_dma_t
Definition: os_defs.h:62
dwc_usb3_close_all_ep
int dwc_usb3_close_all_ep(struct dwc_usb3_device *usb3_dev)
Definition: no_os_gadget.c:602
usb_dfu_functional_descriptor_t::bLength
uByte bLength
Definition: os_defs.h:242
ss_config_desc_t::config_desc
usb_config_descriptor_t config_desc
Definition: os_defs.h:279
task_struct::dummy
int dummy
Definition: os_defs.h:117
usb_request_t::buf
void * buf
Definition: os_defs.h:209
usb_request_t::stream_id
unsigned stream_id
Definition: os_defs.h:213
fs_msc_config_desc_t::bulk_in_ep_desc
usb_endpoint_descriptor_t bulk_in_ep_desc
Definition: os_defs.h:256
dwc_usb3_core_params_t::usb2mode
int usb2mode
Definition: os_defs.h:176
dwc_usb3_core_params_t::lpmctl
int lpmctl
Definition: os_defs.h:174
dwc_usb3_core_params_t::wakeup
int wakeup
Definition: os_defs.h:172
ss_config_desc_t::bulk_in_ep_desc
usb_endpoint_descriptor_t bulk_in_ep_desc
Definition: os_defs.h:281
dwc_usb3_alloc_request
usb_request_t * dwc_usb3_alloc_request(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep)
Definition: no_os_gadget.c:639
dwc_usb3_core_params_t::baseline_besl
int baseline_besl
Definition: os_defs.h:188
dwc_usb3_function_init
int dwc_usb3_function_init(struct dwc_usb3_device *usb3_dev)
dwc_usb3_function_connect
int dwc_usb3_function_connect(struct dwc_usb3_device *usb3_dev, int speed)
u64
unsigned long long u64
Definition: os_defs.h:39
usb_request_t::dma
dwc_dma_t dma
Definition: os_defs.h:211
usb_dfu_functional_descriptor_t::bmAttributes
uByte bmAttributes
Definition: os_defs.h:244
dfu_config_desc_t::config_desc
usb_config_descriptor_t config_desc
Definition: os_defs.h:271
dwc_usb3_core_params_t::hibernate
int hibernate
Definition: os_defs.h:177
tasklet_struct
Definition: os_defs.h:120
UINT8
unsigned char UINT8
Definition: os_defs.h:47
ss_config_desc
ss_config_desc_t ss_config_desc
dwc_usb3_core_params_t::newcore
int newcore
Definition: os_defs.h:170
dwc_usb3_ep_queue
int dwc_usb3_ep_queue(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep, usb_request_t *usb_req)
Definition: no_os_gadget.c:692
usb_request_t::status
int status
Definition: os_defs.h:218
dwc_usb3_core_params_t::newcsr
int newcsr
Definition: os_defs.h:184
dwc_usb3_free_request
void dwc_usb3_free_request(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep, usb_request_t *usb_req)
Definition: no_os_gadget.c:666
usb.h
usb3ss_module_params
const dwc_usb3_core_params_t usb3ss_module_params
dwc_usb3_core_params_t::nobos
int nobos
Definition: os_defs.h:181
s32
int s32
Definition: os_defs.h:50
dwc_usb3_ep_dequeue
int dwc_usb3_ep_dequeue(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep, usb_request_t *usb_req)
Definition: no_os_gadget.c:774
fs_msc_config_desc_t::bulk_out_ep_desc
usb_endpoint_descriptor_t bulk_out_ep_desc
Definition: os_defs.h:257
usb_request_t::actual
unsigned actual
Definition: os_defs.h:219
hs_msc_config_desc_t::bulk_out_ep_desc
usb_endpoint_descriptor_t bulk_out_ep_desc
Definition: os_defs.h:267
fs_msc_config_desc_t::config_desc
usb_config_descriptor_t config_desc
Definition: os_defs.h:254
dwc_usb3_core_params_t::rxfsz
int rxfsz
Definition: os_defs.h:185
fs_msc_config_desc_t::intf_desc
usb_interface_descriptor_t intf_desc
Definition: os_defs.h:255
dwc_usb3_core_params_t::besl
int besl
Definition: os_defs.h:190
dfu_config_desc_t::intf1_desc
usb_interface_descriptor_t intf1_desc
Definition: os_defs.h:273
dwc_usb3_core_params_t::burst
int burst
Definition: os_defs.h:169
dwc_usb3_core_params_t::clkgatingen
int clkgatingen
Definition: os_defs.h:179
usb_dfu_functional_descriptor_t::wTransferSize
uWord wTransferSize
Definition: os_defs.h:246
usb_ep_t::desc
const void * desc
Definition: os_defs.h:199
s8
char s8
Definition: os_defs.h:52
s16
short s16
Definition: os_defs.h:51
u_long
unsigned long u_long
Definition: os_defs.h:54
usb_dfu_functional_descriptor_t::wDetachTimeOut
uWord wDetachTimeOut
Definition: os_defs.h:245
usb_request_t::length
unsigned length
Definition: os_defs.h:210
dwc_usb3_ep_disable
int dwc_usb3_ep_disable(struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep)
Definition: no_os_gadget.c:579
usb_endpoint_descriptor_t
This structure describes a USB endpoint.
Definition: usb.h:317
dwc_usb3_core_params_t
Definition: os_defs.h:168
dwc_usb3_function_disconnect
int dwc_usb3_function_disconnect(struct dwc_usb3_device *usb3_dev)
uWord
u8 uWord[2]
Definition: usb.h:59
uByte
u8 uByte
Definition: usb.h:58
tasklet_struct::dummy
int dummy
Definition: os_defs.h:121
dfu_config_desc_t::dfu_func_desc
usb_dfu_functional_descriptor_t dfu_func_desc
Definition: os_defs.h:274
s64
long long s64
Definition: os_defs.h:49
dwc_usb3_core_params_t::phy
int phy
Definition: os_defs.h:171
usb_request_t
Definition: os_defs.h:208
dwc_usb3_function_remove
void dwc_usb3_function_remove(struct dwc_usb3_device *usb3_dev)
fs_msc_config_desc_t
Definition: os_defs.h:253
u8
unsigned char u8
Definition: os_defs.h:45
dwc_usb3_core_params_t::deep_besl
int deep_besl
Definition: os_defs.h:189
u_char
unsigned char u_char
Definition: os_defs.h:57
usb_dfu_functional_descriptor_t::bcdDFUVersion
uWord bcdDFUVersion
Definition: os_defs.h:248
hs_msc_config_desc_t::intf_desc
usb_interface_descriptor_t intf_desc
Definition: os_defs.h:265
hs_msc_config_desc_t
Definition: os_defs.h:263
dwc_usb3_core_params_t::phyctl
int phyctl
Definition: os_defs.h:175
dwc_usb3_core_params_t::loop
int loop
Definition: os_defs.h:182
dwc_usb3_driver_remove
void dwc_usb3_driver_remove(void)
ss_config_desc_t::bulk_out_ss_ep_comp_desc
ss_endpoint_companion_descriptor_t bulk_out_ss_ep_comp_desc
Definition: os_defs.h:284