arcusb_hprv.h
9.47 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#ifndef __usbhprv_h__
#define __usbhprv_h__ 1
/*HEADER******************************************************************
**************************************************************************
***
*** Copyright (c) 2001-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: usbhprv.h
***
*** Comments:
*** This file contains the internal USB Host speicifc type definitions
***
**************************************************************************
*END*********************************************************************/
#define USBERR_ALLOC_BD_TABLE (0xFE)
/***************************************
**
** Code macros
**
*/
/*
* Mutual exclusion for USB on BBPLAYER is masking interrupts
* while manipulating data structures shared between the interrupt
* threads and the top half
*/
#define USB_lock() __usb_splhigh()
#define USB_unlock() __usb_splx()
/* Setup */
typedef struct
{
uint_8 BREQUESTTYPE; /* (bits 6:5 must be 00) */
uint_8 BREQUEST;
uint_16 WVALUE;
uint_16 WINDEX;
uint_16 WLENGTH;
} INTERNAL_USB_SETUP, _PTR_ INTERNAL_USB_SETUP_PTR;
/* Callback function storage structure */
typedef struct host_service_struct {
uint_32 TYPE;
void (_CODE_PTR_ SERVICE)(pointer, uint_32);
struct host_service_struct _PTR_ NEXT;
} USB_SERVICE_STRUCT, _PTR_ USB_SERVICE_STRUCT_PTR;
typedef struct
{
uint_8 ADDRESS; /* USB bus address */
uint_8 EP; /* Endpoint number */
uint_8 DIRECTION; /* Direction - Rx or Tx */
uint_8 INTERVAL; /* Interval for transfer */
uint_8 PIPETYPE; /* Pipe type - Ctrl, Iso, Int, Bulk */
uint_8 CURRENT_INTERVAL;
uint_8 NAK_COUNT;
uint_8 CURRENT_NAK_COUNT;
uint_8 USB_PIPE_TRANSACTION_STATE;
uint_8 STATUS; /* 0: Current transfer status */
uint_8 NEXTDATA01; /* Data 0/1 synch bit for the PID */
uint_8 MUSTSENDNULL; /* Status stage of control transfer */
uint_32 SOFAR; /* number of bytes sent/recv'd so far */
uint_32 TODO1; /* number of bytes to send for first
** phase
*/
uint_32 TODO2; /* number of bytes to send for second
** phase
*/
uint_16 MAX_PKT_SIZE; /* Max packet size for this pipe */
int_16 PIPE_ID; /* Pipe ID */
int_16 NEXT_PIPE; /* Next pipe id for the same type of
** pkt
*/
boolean OPEN;
boolean SEND_PHASE; /* Second phase of setup packet:
** Send/Receive
*/
boolean PACKETPENDING; /* Transaction pending */
uchar_ptr TX1_PTR; /* address of transmit buffer for
** first phase
*/
uchar_ptr TX2_PTR; /* address of transmit buffer for
** second phase
*/
uchar_ptr RX_PTR; /* address of receive buffer */
boolean FIRST_PHASE;
/* Terminate xfer with zero length packet */
boolean DONT_ZERO_TERMINATE;
uint_8 RESERVED[PIPE_RESERVED_FOR_ALIGNMENT];
} PIPE_DESCRIPTOR_STRUCT, _PTR_ PIPE_DESCRIPTOR_STRUCT_PTR;
typedef struct usb_host_state_structure {
USB_STRUCT_PTR DEV_PTR;
HOST_BDT_STRUCT_PTR USB_BDT_PAGE;
USB_REGISTER_PTR ENDPT_HOST_RG;
USB_SERVICE_STRUCT_PTR SERVICE_HEAD_PTR;
PIPE_DESCRIPTOR_STRUCT_PTR PIPE_DESCRIPTOR_BASE_PTR;
pointer CALLBACK_STRUCT_PTR;
HOST_BDT_STRUCT_PTR CURRENT_BDT;
uint_8 CTLR_NUM;
uint_8 DEV_NUM;
uint_8 USB_OUT;
uint_8 USB_IN;
/* we now use these even when we aren't buffering tokens for xmit on the
** next token_done this is so we can re-xmit if an error is returned
*/
uint_8 USB_BUFFERED;
uint_8 USB_BUFFERED_TOKEN;
uint_8 USB_BUFFERED_ADDRESS;
uint_8 USB_BUFFERED_TYPE;
uint_8 USB_NEXT_BUFFERED_ADDRESS;
uint_8 USB_NEXT_BUFFERED_TOKEN;
uint_8 USB_NEXT_BUFFERED_TYPE;
uint_8 USB_PKT_PENDING;
uint_8 NO_HUB;
uint_8 SPEED;
uint_8 MAX_PIPES;
HOST_BDT_STRUCT USB_BUFFERED_BDT;
HOST_BDT_STRUCT USB_NEXT_BUFFERED_BDT;
HOST_BDT_STRUCT USB_TEMP_SND_BDT;
HOST_BDT_STRUCT USB_TEMP_RCV_BDT;
boolean SND_TOK_IN_PROGRESS;
boolean NEXT_PKT_QUEUED;
boolean USB_TOKEN_BUFFERED;
int_16 TOK_THIS_FRAME;
int_16 CTRL_PIPE1;
int_16 CURRENT_PIPE_ID;
int_16 NEXT_PIPE_ID;
int_16 CURRENT_ISO_HEAD;
int_16 CURRENT_ISO_TAIL;
int_16 CURRENT_INTR_HEAD;
int_16 CURRENT_INTR_TAIL;
int_16 CURRENT_CTRL_HEAD;
int_16 CURRENT_CTRL_TAIL;
int_16 CURRENT_BULK_HEAD;
int_16 CURRENT_BULK_TAIL;
} USB_HOST_STATE_STRUCT, _PTR_ USB_HOST_STATE_STRUCT_PTR;
/* Prototypes */
#ifdef __cplusplus
extern "C" {
#endif
extern void _usb_hci_vusb11_isr(_usb_host_handle);
extern void _usb_host_delay(_usb_host_handle, uint_32);
extern void _usb_host_vusb11_reset_the_device(_usb_host_handle);
extern void _usb_host_vusb11_process_attach(_usb_host_handle);
extern void _usb_host_vusb11_process_detach(_usb_host_handle);
extern void _usb_host_vusb11_process_token_done(_usb_host_handle, uint_8,
uint_32);
extern void _usb_host_vusb11_pipe_transaction_state_02(_usb_host_handle);
extern HOST_BDT_STRUCT_PTR _usb_host_vusb11_get_next_in_bdt(_usb_host_handle);
extern HOST_BDT_STRUCT_PTR _usb_host_vusb11_get_next_out_bdt(_usb_host_handle);
extern uint_8 _bsp_get_usb_vector(uint_8);
extern pointer _bsp_get_usb_base(uint_8);
extern void _usb_host_vusb11_set_bdt_page(_usb_host_handle);
extern void _usb_host_vusb11_init_send_bdt(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_host_vusb11_init_setup_bdt(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_host_vusb11_init_recv_bdt(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_host_vusb11_sched_pending_pkts(_usb_host_handle);
extern void _usb_host_vusb11_sched_iso_pkts(_usb_host_handle);
extern void _usb_host_buffer_bdt(_usb_host_handle, HOST_BDT_STRUCT_PTR);
extern void _usb_host_buffer_next_bdt(_usb_host_handle, HOST_BDT_STRUCT_PTR);
extern void _usb_host_queue_pkts(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_host_update_current_head(_usb_host_handle, uint_8);
extern void _usb_host_update_interval_for_pipes(_usb_host_handle);
extern void _usb_host_vusb11_send_in_token(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_host_vusb11_send_out_token(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_host_vusb11_send_token(_usb_host_handle, uint_8, uint_8, uint_8);
extern void _usb_host_vusb11_resend_token(_usb_host_handle, uint_8);
extern void _usb_host_buffer_token(_usb_host_handle, uint_8, uint_8, uint_8);
extern void _usb_host_buffer_next_token(_usb_host_handle, uint_8, uint_8, uint_8);
extern void _usb_host_vusb11_initiate_correct_bdt(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern uint_8 _usb_hci_vusb11_init(_usb_host_handle);
extern void _usb_hci_vusb11_send_data(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_hci_vusb11_send_setup(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_hci_vusb11_recv_data(_usb_host_handle, PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_hci_vusb11_cancel_transfer(_usb_host_handle,
PIPE_DESCRIPTOR_STRUCT_PTR);
extern void _usb_hci_vusb11_bus_control(_usb_host_handle, uint_8);
extern void _usb_hci_vusb11_shutdown(_usb_host_handle);
#ifdef __cplusplus
}
#endif
#endif /* __usbhprv_h__ */