host.h
4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef _host_h_
#define _host_h_ 1
/*HEADER****************************************************************
************************************************************************
***
*** Copyright (c) 1992-2002 ARC International
*** All rights reserved
***
*** This software embodies materials and concepts which are
*** confidential to ARC International and is made available solely
*** pursuant to the terms of a written license agreement with
*** ARC International.
***
*** File: host.h
***
*** Comments:
***
***
************************************************************************
*END*******************************************************************/
#ifdef USB_DEBUG
extern int dramPrintf(const char *fmt, ...);
extern void drambufswitch(int);
#define PRINTF dramPrintf
#define printf dramPrintf
#else
#define PRINTF(format, args...)
#define printf(format, args...)
#define drambufswitch(i)
#endif /* !USB_DEBUG */
#define USB_STR_SIZE 64
#define DEMO_CONFIG_DESC_SIZE 64
#define BIDIRECTIONAL 0x4d
/* Setup */
typedef struct
{
uchar BREQUESTTYPE;
uchar BREQUEST;
uint_16 WVALUE;
uint_16 WINDEX;
uint_16 WLENGTH;
} USB_SETUP, _PTR_ USB_SETUP_PTR;
/* Standard Device decriptors */
typedef struct dev_desc
{
uchar BLENGTH;
uchar BDESCTYPE;
uint_16 BCDUSB;
uchar BDEVICECLASS;
uchar BDEVICESUBCLASS;
uchar BDEVICEPROTOCOL;
uchar BMAXPACKETSIZE;
uint_16 IDVENDOR;
uint_16 IDPRODUCT;
uint_16 BCDDEVICE;
uchar BMANUFACTURER;
uchar BPRODUCT;
uchar BSERIALNUMBER;
uchar BNUMCONFIGURATIONS;
} USB_DEV_DESC, _PTR_ USB_DEV_DESC_PTR, usb_dev_desc;
typedef struct usb_host_driver_funcs_s {
int (*match)(usb_dev_desc *);
void (*open)(_usb_host_handle);
void (*poll)(_usb_host_handle);
void (*send)(_usb_host_handle, u8 *, s32, u64);
void (*recv)(_usb_host_handle, u8 *, s32, u64);
void (*detach)(_usb_host_handle, uint_32);
void (*chap9)(_usb_host_handle);
} usb_host_driver_funcs;
/*
* Host USB driver definition
*
* Each host side driver registers one of these structures
* to allow the generic host code to recognize the device
* and access the device specific driver functions.
*/
typedef struct usb_host_driver_s {
usb_dev_desc *desc;
usb_host_driver_funcs *funcs;
char *name;
} usb_host_driver;
/*
* External handle used by libultra API
*/
typedef struct _usb_ext_handle_s {
s32 uh_which;
s32 uh_blksize;
OSMesgQueue *uh_mq;
_usb_host_handle uh_host_handle;
__OSBbUsbMesg *uh_wr_msg;
u8 *uh_wr_buffer;
u64 uh_wr_offset;
s32 uh_wr_len;
__OSBbUsbMesg *uh_rd_msg;
u8 *uh_rd_buffer;
u64 uh_rd_offset;
s32 uh_rd_len;
} _usb_ext_handle;
/*
* Global state for each USB host controller
*/
typedef volatile struct host_global_struct
{
uint_8 USB_CURRENT_ADDRESS;
uint_8 DEVICE_ADDRESS;
int_16 DEFAULT_PIPE;
volatile boolean DEVICE_ATTACHED;
volatile boolean ENUMERATION_DONE;
volatile boolean REGISTER_SERVICES;
volatile boolean TRANSACTION_COMPLETE;
volatile uint_8 ENUMERATION_STATE;
uchar RX_TEST_BUFFER[20];
USB_DEV_DESC RX_DESC_DEVICE;
uint_8 RX_CONFIG_DESC[DEMO_CONFIG_DESC_SIZE];
uchar MFG_STR[USB_STR_SIZE];
uchar PROD_STR[USB_STR_SIZE];
usb_host_driver *driver;
_usb_ext_handle *curhandle;
} HOST_GLOBAL_STRUCT, _PTR_ HOST_GLOBAL_STRUCT_PTR;
extern HOST_GLOBAL_STRUCT host_global_struct[OS_USB_MAX_CONTROLLERS];
extern _usb_host_handle __osArcHostHandle[OS_USB_MAX_CONTROLLERS];
extern _usb_ext_handle _usb_ext_handles[OS_USB_MAX_HANDLES];
extern USB_SETUP tx_get_status;
extern USB_SETUP tx_clear_feature;
extern USB_SETUP tx_set_feature;
extern USB_SETUP tx_synch_frame;
extern USB_SETUP tx_get_desc;
extern USB_SETUP tx_get_config_desc;
extern USB_SETUP tx_set_address;
extern USB_SETUP tx_get_config;
extern USB_SETUP tx_set_config;
extern USB_SETUP tx_set_interface;
extern USB_SETUP tx_get_interface;
extern USB_SETUP tx_get_alt_interface;
extern USB_SETUP tx_get_port_status;
#ifdef __cplusplus
extern "C" {
#endif
extern void __usb_service_ep0(_usb_device_handle, boolean, uint_8, uint_8_ptr, uint_32);
extern void __usb_reset_ep0(_usb_device_handle, boolean, uint_8, uint_8_ptr, uint_32);
extern void __usb_host_driver_register(usb_host_driver *);
extern void __usb_host_chapter9_negotiation(s32);
extern void __usb_host_process_attach(_usb_host_handle, uint_32);
extern void __usb_host_process_detach(_usb_host_handle, uint_32);
extern void __usb_host_process_host_resume(_usb_host_handle, uint_32);
extern void __usb_host_process_default_pipe(_usb_host_handle, uint_32);
extern void __usb_host_process_pipe_transaction_done(_usb_host_handle, uint_32);
extern void __usb_bus_sof(_usb_device_handle, boolean, uint_8, uint_8_ptr, uint_32);
#ifdef __cplusplus
}
#endif
#endif /* _host_h_ */