2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2008 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_USBTRANS_H
20 #define GRUB_USBTRANS_H 1
22 #define MAX_USB_TRANSFER_LEN 0x0800
26 GRUB_USB_TRANSFER_TYPE_IN
,
27 GRUB_USB_TRANSFER_TYPE_OUT
,
28 GRUB_USB_TRANSFER_TYPE_SETUP
29 } grub_transfer_type_t
;
33 GRUB_USB_TRANSACTION_TYPE_CONTROL
,
34 GRUB_USB_TRANSACTION_TYPE_BULK
35 } grub_transaction_type_t
;
37 struct grub_usb_transaction
41 grub_transfer_type_t pid
;
43 grub_size_t preceding
;
45 typedef struct grub_usb_transaction
*grub_usb_transaction_t
;
47 struct grub_usb_transfer
59 grub_transaction_type_t type
;
61 grub_transfer_type_t dir
;
63 struct grub_usb_device
*dev
;
65 struct grub_usb_transaction
*transactions
;
68 /* Index of last processed transaction in OHCI/UHCI driver. */
70 void *controller_data
;
72 /* Used when finishing transfer to copy data back. */
73 struct grub_pci_dma_chunk
*data_chunk
;
76 typedef struct grub_usb_transfer
*grub_usb_transfer_t
;
82 GRUB_USB_REQTYPE_TARGET_DEV
= (0 << 0),
83 GRUB_USB_REQTYPE_TARGET_INTERF
= (1 << 0),
84 GRUB_USB_REQTYPE_TARGET_ENDP
= (2 << 0),
85 GRUB_USB_REQTYPE_TARGET_OTHER
= (3 << 0),
86 GRUB_USB_REQTYPE_STANDARD
= (0 << 5),
87 GRUB_USB_REQTYPE_CLASS
= (1 << 5),
88 GRUB_USB_REQTYPE_VENDOR
= (2 << 5),
89 GRUB_USB_REQTYPE_OUT
= (0 << 7),
90 GRUB_USB_REQTYPE_IN
= (1 << 7),
91 GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT
= GRUB_USB_REQTYPE_TARGET_INTERF
92 | GRUB_USB_REQTYPE_CLASS
| GRUB_USB_REQTYPE_OUT
,
93 GRUB_USB_REQTYPE_VENDOR_OUT
= GRUB_USB_REQTYPE_VENDOR
| GRUB_USB_REQTYPE_OUT
,
94 GRUB_USB_REQTYPE_CLASS_INTERFACE_IN
= GRUB_USB_REQTYPE_TARGET_INTERF
95 | GRUB_USB_REQTYPE_CLASS
| GRUB_USB_REQTYPE_IN
,
96 GRUB_USB_REQTYPE_VENDOR_IN
= GRUB_USB_REQTYPE_VENDOR
| GRUB_USB_REQTYPE_IN
101 GRUB_USB_REQ_GET_STATUS
= 0x00,
102 GRUB_USB_REQ_CLEAR_FEATURE
= 0x01,
103 GRUB_USB_REQ_SET_FEATURE
= 0x03,
104 GRUB_USB_REQ_SET_ADDRESS
= 0x05,
105 GRUB_USB_REQ_GET_DESCRIPTOR
= 0x06,
106 GRUB_USB_REQ_SET_DESCRIPTOR
= 0x07,
107 GRUB_USB_REQ_GET_CONFIGURATION
= 0x08,
108 GRUB_USB_REQ_SET_CONFIGURATION
= 0x09,
109 GRUB_USB_REQ_GET_INTERFACE
= 0x0A,
110 GRUB_USB_REQ_SET_INTERFACE
= 0x0B,
111 GRUB_USB_REQ_SYNC_FRAME
= 0x0C
114 #define GRUB_USB_FEATURE_ENDP_HALT 0x00
115 #define GRUB_USB_FEATURE_DEV_REMOTE_WU 0x01
116 #define GRUB_USB_FEATURE_TEST_MODE 0x02
120 GRUB_USB_HUB_FEATURE_PORT_RESET
= 0x04,
121 GRUB_USB_HUB_FEATURE_PORT_POWER
= 0x08,
122 GRUB_USB_HUB_FEATURE_C_PORT_CONNECTED
= 0x10,
123 GRUB_USB_HUB_FEATURE_C_PORT_ENABLED
= 0x11,
124 GRUB_USB_HUB_FEATURE_C_PORT_SUSPEND
= 0x12,
125 GRUB_USB_HUB_FEATURE_C_PORT_OVERCURRENT
= 0x13,
126 GRUB_USB_HUB_FEATURE_C_PORT_RESET
= 0x14
131 GRUB_USB_HUB_STATUS_PORT_CONNECTED
= (1 << 0),
132 GRUB_USB_HUB_STATUS_PORT_ENABLED
= (1 << 1),
133 GRUB_USB_HUB_STATUS_PORT_SUSPEND
= (1 << 2),
134 GRUB_USB_HUB_STATUS_PORT_OVERCURRENT
= (1 << 3),
135 GRUB_USB_HUB_STATUS_PORT_POWERED
= (1 << 8),
136 GRUB_USB_HUB_STATUS_PORT_LOWSPEED
= (1 << 9),
137 GRUB_USB_HUB_STATUS_PORT_HIGHSPEED
= (1 << 10),
138 GRUB_USB_HUB_STATUS_C_PORT_CONNECTED
= (1 << 16),
139 GRUB_USB_HUB_STATUS_C_PORT_ENABLED
= (1 << 17),
140 GRUB_USB_HUB_STATUS_C_PORT_SUSPEND
= (1 << 18),
141 GRUB_USB_HUB_STATUS_C_PORT_OVERCURRENT
= (1 << 19),
142 GRUB_USB_HUB_STATUS_C_PORT_RESET
= (1 << 20)
145 struct grub_usb_packet_setup
147 grub_uint8_t reqtype
;
148 grub_uint8_t request
;
151 grub_uint16_t length
;
155 #endif /* GRUB_USBTRANS_H */