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/>.
22 #include <grub/usbdesc.h>
23 #include <grub/usbtrans.h>
25 typedef struct grub_usb_device
*grub_usb_device_t
;
26 typedef struct grub_usb_controller
*grub_usb_controller_t
;
27 typedef struct grub_usb_controller_dev
*grub_usb_controller_dev_t
;
32 GRUB_USB_ERR_INTERNAL
,
49 /* Call HOOK with each device, until HOOK returns non-zero. */
50 int grub_usb_iterate (int (*hook
) (grub_usb_device_t dev
));
52 grub_usb_err_t
grub_usb_device_initialize (grub_usb_device_t dev
);
54 grub_usb_err_t
grub_usb_get_descriptor (grub_usb_device_t dev
,
55 grub_uint8_t type
, grub_uint8_t index
,
56 grub_size_t size
, char *data
);
58 struct grub_usb_desc_endp
*
59 grub_usb_get_endpdescriptor (grub_usb_device_t usbdev
, int addr
);
61 grub_usb_err_t
grub_usb_clear_halt (grub_usb_device_t dev
, int endpoint
);
64 grub_usb_err_t
grub_usb_set_configuration (grub_usb_device_t dev
,
67 grub_usb_err_t
grub_usb_get_string (grub_usb_device_t dev
, grub_uint8_t index
,
68 int langid
, char **string
);
70 void grub_usb_controller_dev_register (grub_usb_controller_dev_t usb
);
72 void grub_usb_controller_dev_unregister (grub_usb_controller_dev_t usb
);
74 int grub_usb_controller_iterate (int (*hook
) (grub_usb_controller_t dev
));
77 grub_usb_err_t
grub_usb_control_msg (grub_usb_device_t dev
, grub_uint8_t reqtype
,
78 grub_uint8_t request
, grub_uint16_t value
,
79 grub_uint16_t index
, grub_size_t size
,
83 grub_usb_bulk_read (grub_usb_device_t dev
,
84 int endpoint
, grub_size_t size
, char *data
);
86 grub_usb_bulk_write (grub_usb_device_t dev
,
87 int endpoint
, grub_size_t size
, char *data
);
90 grub_usb_root_hub (grub_usb_controller_t controller
);
93 /* XXX: All handled by libusb for now. */
94 struct grub_usb_controller_dev
96 /* The device name. */
99 int (*iterate
) (int (*hook
) (grub_usb_controller_t dev
));
101 grub_usb_err_t (*transfer
) (grub_usb_controller_t dev
,
102 grub_usb_transfer_t transfer
);
104 int (*hubports
) (grub_usb_controller_t dev
);
106 grub_err_t (*portstatus
) (grub_usb_controller_t dev
, unsigned int port
,
107 unsigned int enable
);
109 grub_usb_speed_t (*detect_dev
) (grub_usb_controller_t dev
, int port
);
111 /* The next host controller. */
112 struct grub_usb_controller_dev
*next
;
115 struct grub_usb_controller
117 /* The underlying USB Host Controller device. */
118 grub_usb_controller_dev_t dev
;
120 /* Data used by the USB Host Controller Driver. */
125 struct grub_usb_interface
127 struct grub_usb_desc_if
*descif
;
129 struct grub_usb_desc_endp
*descendp
;
132 struct grub_usb_configuration
134 /* Configuration descriptors . */
135 struct grub_usb_desc_config
*descconf
;
137 /* Interfaces associated to this configuration. */
138 struct grub_usb_interface interf
[32];
141 struct grub_usb_device
143 /* The device descriptor of this device. */
144 struct grub_usb_desc_device descdev
;
146 /* The controller the device is connected to. */
147 struct grub_usb_controller controller
;
149 /* Device configurations (after opening the device). */
150 struct grub_usb_configuration config
[8];
152 /* Device address. */
156 grub_usb_speed_t speed
;
158 /* All descriptors are read if this is set to 1. */
161 /* Data toggle values (used for bulk transfers only). */
164 /* Device-specific data. */
172 GRUB_USB_CLASS_NOTHERE
,
173 GRUB_USB_CLASS_AUDIO
,
174 GRUB_USB_CLASS_COMMUNICATION
,
177 GRUB_USB_CLASS_PHYSICAL
,
178 GRUB_USB_CLASS_IMAGE
,
179 GRUB_USB_CLASS_PRINTER
,
180 GRUB_USB_CLASS_MASS_STORAGE
,
182 GRUB_USB_CLASS_DATA_INTERFACE
,
183 GRUB_USB_CLASS_SMART_CARD
,
184 GRUB_USB_CLASS_CONTENT_SECURITY
,
186 } grub_usb_classes_t
;
190 GRUB_USBMS_SUBCLASS_BULK
= 0x06
191 } grub_usbms_subclass_t
;
195 GRUB_USBMS_PROTOCOL_BULK
= 0x50
196 } grub_usbms_protocol_t
;
198 static inline struct grub_usb_desc_if
*
199 grub_usb_get_config_interface (struct grub_usb_desc_config
*config
)
201 struct grub_usb_desc_if
*interf
;
203 interf
= (struct grub_usb_desc_if
*) (sizeof (*config
) + (char *) config
);
207 #endif /* GRUB_USB_H */