Add possibility of bulk reading with short timeout
This commit is contained in:
parent
aa86530e38
commit
d556277751
4 changed files with 26 additions and 10 deletions
|
@ -654,7 +654,7 @@ grub_ohci_transaction (grub_ohci_td_t td,
|
||||||
|
|
||||||
static grub_usb_err_t
|
static grub_usb_err_t
|
||||||
grub_ohci_transfer (grub_usb_controller_t dev,
|
grub_ohci_transfer (grub_usb_controller_t dev,
|
||||||
grub_usb_transfer_t transfer)
|
grub_usb_transfer_t transfer, int timeout)
|
||||||
{
|
{
|
||||||
struct grub_ohci *o = (struct grub_ohci *) dev->data;
|
struct grub_ohci *o = (struct grub_ohci *) dev->data;
|
||||||
grub_ohci_ed_t ed_virt;
|
grub_ohci_ed_t ed_virt;
|
||||||
|
@ -832,7 +832,7 @@ grub_ohci_transfer (grub_usb_controller_t dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Safety measure to avoid a hang. */
|
/* Safety measure to avoid a hang. */
|
||||||
maxtime = grub_get_time_ms () + 1000;
|
maxtime = grub_get_time_ms () + timeout;
|
||||||
|
|
||||||
/* Wait until the transfer is completed or STALLs. */
|
/* Wait until the transfer is completed or STALLs. */
|
||||||
do
|
do
|
||||||
|
|
|
@ -436,7 +436,8 @@ grub_uhci_transaction (struct grub_uhci *u, unsigned int endp,
|
||||||
|
|
||||||
static grub_usb_err_t
|
static grub_usb_err_t
|
||||||
grub_uhci_transfer (grub_usb_controller_t dev,
|
grub_uhci_transfer (grub_usb_controller_t dev,
|
||||||
grub_usb_transfer_t transfer)
|
grub_usb_transfer_t transfer,
|
||||||
|
int timeout)
|
||||||
{
|
{
|
||||||
struct grub_uhci *u = (struct grub_uhci *) dev->data;
|
struct grub_uhci *u = (struct grub_uhci *) dev->data;
|
||||||
grub_uhci_qh_t qh;
|
grub_uhci_qh_t qh;
|
||||||
|
@ -496,7 +497,7 @@ grub_uhci_transfer (grub_usb_controller_t dev,
|
||||||
|
|
||||||
/* Wait until either the transaction completed or an error
|
/* Wait until either the transaction completed or an error
|
||||||
occurred. */
|
occurred. */
|
||||||
endtime = grub_get_time_ms () + 1000;
|
endtime = grub_get_time_ms () + timeout;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
grub_uhci_td_t errtd;
|
grub_uhci_td_t errtd;
|
||||||
|
|
|
@ -145,7 +145,7 @@ grub_usb_control_msg (grub_usb_device_t dev,
|
||||||
|
|
||||||
transfer->transactions[datablocks + 1].toggle = 1;
|
transfer->transactions[datablocks + 1].toggle = 1;
|
||||||
|
|
||||||
err = dev->controller.dev->transfer (&dev->controller, transfer);
|
err = dev->controller.dev->transfer (&dev->controller, transfer, 1000);
|
||||||
grub_dprintf ("usb", "control: err=%d\n", err);
|
grub_dprintf ("usb", "control: err=%d\n", err);
|
||||||
|
|
||||||
grub_free (transfer->transactions);
|
grub_free (transfer->transactions);
|
||||||
|
@ -162,7 +162,7 @@ grub_usb_control_msg (grub_usb_device_t dev,
|
||||||
static grub_usb_err_t
|
static grub_usb_err_t
|
||||||
grub_usb_bulk_readwrite (grub_usb_device_t dev,
|
grub_usb_bulk_readwrite (grub_usb_device_t dev,
|
||||||
int endpoint, grub_size_t size0, char *data_in,
|
int endpoint, grub_size_t size0, char *data_in,
|
||||||
grub_transfer_type_t type)
|
grub_transfer_type_t type, int timeout)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
grub_usb_transfer_t transfer;
|
grub_usb_transfer_t transfer;
|
||||||
|
@ -243,7 +243,7 @@ grub_usb_bulk_readwrite (grub_usb_device_t dev,
|
||||||
size -= tr->size;
|
size -= tr->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dev->controller.dev->transfer (&dev->controller, transfer);
|
err = dev->controller.dev->transfer (&dev->controller, transfer, timeout);
|
||||||
/* We must remember proper toggle value even if some transactions
|
/* We must remember proper toggle value even if some transactions
|
||||||
* were not processed - correct value should be inversion of last
|
* were not processed - correct value should be inversion of last
|
||||||
* processed transaction (TD). */
|
* processed transaction (TD). */
|
||||||
|
@ -269,7 +269,7 @@ grub_usb_bulk_write (grub_usb_device_t dev,
|
||||||
int endpoint, grub_size_t size, char *data)
|
int endpoint, grub_size_t size, char *data)
|
||||||
{
|
{
|
||||||
return grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
return grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
||||||
GRUB_USB_TRANSFER_TYPE_OUT);
|
GRUB_USB_TRANSFER_TYPE_OUT, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_usb_err_t
|
grub_usb_err_t
|
||||||
|
@ -277,5 +277,14 @@ grub_usb_bulk_read (grub_usb_device_t dev,
|
||||||
int endpoint, grub_size_t size, char *data)
|
int endpoint, grub_size_t size, char *data)
|
||||||
{
|
{
|
||||||
return grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
return grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
||||||
GRUB_USB_TRANSFER_TYPE_IN);
|
GRUB_USB_TRANSFER_TYPE_IN, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_usb_err_t
|
||||||
|
grub_usb_bulk_read_timeout (grub_usb_device_t dev,
|
||||||
|
int endpoint, grub_size_t size, char *data,
|
||||||
|
int timeout)
|
||||||
|
{
|
||||||
|
return grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
||||||
|
GRUB_USB_TRANSFER_TYPE_IN, timeout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ typedef enum
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT = 0x21,
|
||||||
GRUB_USB_REQTYPE_VENDOR_OUT = 0x40
|
GRUB_USB_REQTYPE_VENDOR_OUT = 0x40
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,7 +104,8 @@ struct grub_usb_controller_dev
|
||||||
int (*iterate) (int (*hook) (grub_usb_controller_t dev));
|
int (*iterate) (int (*hook) (grub_usb_controller_t dev));
|
||||||
|
|
||||||
grub_usb_err_t (*transfer) (grub_usb_controller_t dev,
|
grub_usb_err_t (*transfer) (grub_usb_controller_t dev,
|
||||||
grub_usb_transfer_t transfer);
|
grub_usb_transfer_t transfer,
|
||||||
|
int timeout);
|
||||||
|
|
||||||
int (*hubports) (grub_usb_controller_t dev);
|
int (*hubports) (grub_usb_controller_t dev);
|
||||||
|
|
||||||
|
@ -235,5 +237,9 @@ void grub_usb_unregister_attach_hook_class (struct grub_usb_attach_desc *desc);
|
||||||
void grub_usb_poll_devices (void);
|
void grub_usb_poll_devices (void);
|
||||||
|
|
||||||
void grub_usb_device_attach (grub_usb_device_t dev);
|
void grub_usb_device_attach (grub_usb_device_t dev);
|
||||||
|
grub_usb_err_t
|
||||||
|
grub_usb_bulk_read_timeout (grub_usb_device_t dev,
|
||||||
|
int endpoint, grub_size_t size, char *data,
|
||||||
|
int timeout);
|
||||||
|
|
||||||
#endif /* GRUB_USB_H */
|
#endif /* GRUB_USB_H */
|
||||||
|
|
Loading…
Reference in a new issue