iPXE
|
USB mass storage driver. More...
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <ipxe/usb.h>
#include <ipxe/scsi.h>
#include <ipxe/xfer.h>
#include <ipxe/uri.h>
#include <ipxe/open.h>
#include <ipxe/efi/efi_path.h>
#include "usbblk.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | usbblk_stop (struct usbblk_device *usbblk, int rc) |
Stop SCSI command. More... | |
static | LIST_HEAD (usbblk_devices) |
List of USB block devices. More... | |
static int | usbblk_open (struct usbblk_device *usbblk) |
Open endpoints. More... | |
static void | usbblk_close (struct usbblk_device *usbblk) |
Close endpoints. More... | |
static int | usbblk_out_command (struct usbblk_device *usbblk) |
Issue bulk OUT command. More... | |
static int | usbblk_out_data (struct usbblk_device *usbblk) |
Send bulk OUT data block. More... | |
static int | usbblk_out_refill (struct usbblk_device *usbblk) |
Refill bulk OUT endpoint. More... | |
static void | usbblk_out_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk OUT transfer. More... | |
static int | usbblk_in_data (struct usbblk_device *usbblk, const void *data, size_t len) |
Handle bulk IN data block. More... | |
static int | usbblk_in_status (struct usbblk_device *usbblk, const void *data, size_t len) |
Handle bulk IN status. More... | |
static int | usbblk_in_refill (struct usbblk_device *usbblk) |
Refill bulk IN endpoint. More... | |
static void | usbblk_in_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk IN transfer. More... | |
static void | usbblk_step (struct usbblk_device *usbblk) |
Refill endpoints. More... | |
static int | usbblk_start (struct usbblk_device *usbblk, struct scsi_cmd *scsicmd) |
Start new SCSI command. More... | |
static size_t | usbblk_scsi_window (struct usbblk_device *usbblk) |
Check SCSI command flow-control window. More... | |
static int | usbblk_scsi_command (struct usbblk_device *usbblk, struct interface *data, struct scsi_cmd *scsicmd) |
Issue SCSI command. More... | |
static void | usbblk_scsi_close (struct usbblk_device *usbblk, int rc) |
Close SCSI interface. More... | |
static EFI_DEVICE_PATH_PROTOCOL * | usbblk_efi_describe (struct usbblk_device *usbblk) |
Describe as an EFI device path. More... | |
static struct usbblk_device * | usbblk_find (const char *name) |
Find USB block device. More... | |
static int | usbblk_open_uri (struct interface *parent, struct uri *uri) |
Open USB block device URI. More... | |
static int | usbblk_probe (struct usb_function *func, struct usb_configuration_descriptor *config) |
Probe device. More... | |
static void | usbblk_remove (struct usb_function *func) |
Remove device. More... | |
Variables | |
static struct usb_endpoint_driver_operations | usbblk_out_operations |
Bulk OUT endpoint operations. More... | |
static struct usb_endpoint_driver_operations | usbblk_in_operations |
Bulk IN endpoint operations. More... | |
static struct process_descriptor | usbblk_process_desc |
Refill process descriptor. More... | |
static uint16_t | usbblk_tag |
Next command tag. More... | |
static struct interface_operation | usbblk_data_operations [] |
SCSI data interface operations. More... | |
static struct interface_descriptor | usbblk_data_desc |
SCSI data interface descriptor. More... | |
static struct interface_operation | usbblk_scsi_operations [] |
SCSI command interface operations. More... | |
static struct interface_descriptor | usbblk_scsi_desc |
SCSI command interface descriptor. More... | |
struct uri_opener usbblk_uri_opener | __uri_opener |
USB block device URI opener. More... | |
static struct usb_device_id | usbblk_ids [] |
Mass storage class device IDs. More... | |
struct usb_driver usbblk_driver | __usb_driver |
Mass storage driver. More... | |
USB mass storage driver.
Definition in file usbblk.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Stop SCSI command.
usbblk | USB block device |
rc | Reason for stop |
Definition at line 552 of file usbblk.c.
References usbblk_device::cmd, usbblk_device::data, DBGC, usbblk_device::func, intf_restart(), memset(), usb_function::name, usbblk_device::process, process_del(), rc, and usbblk_close().
Referenced by usbblk_in_complete(), usbblk_in_status(), usbblk_out_complete(), usbblk_scsi_close(), and usbblk_scsi_command().
|
static |
List of USB block devices.
|
static |
Open endpoints.
usbblk | USB block device |
rc | Return status code |
Definition at line 61 of file usbblk.c.
References assert(), DBGC, usbblk_device::func, usbblk_device::in, usb_function::name, NULL, usb_endpoint::open, usbblk_device::out, rc, strerror(), usb_function::usb, usb_control(), usb_endpoint_clear_halt(), usb_endpoint_close(), usb_endpoint_open(), and USBBLK_RESET.
Referenced by usbblk_scsi_command().
|
static |
Close endpoints.
usbblk | USB block device |
Definition at line 123 of file usbblk.c.
References usbblk_device::in, usb_endpoint::open, usbblk_device::out, and usb_endpoint_close().
Referenced by usbblk_scsi_close(), usbblk_scsi_command(), and usbblk_stop().
|
static |
Issue bulk OUT command.
usbblk | USB block device |
rc | Return status code |
Definition at line 147 of file usbblk.c.
References alloc_iob(), assert(), usbblk_command_wrapper::cb, usbblk_command_wrapper::cblen, cmd, usbblk_device::cmd, cpu_to_le32, DBGC, ENOMEM, usbblk_command_wrapper::flags, free_iob(), usbblk_device::func, iob_put, usbblk_command_wrapper::len, usbblk_command_wrapper::lun, memcpy(), memset(), usb_function::name, ntohs, usbblk_device::out, rc, usbblk_command_wrapper::signature, strerror(), usbblk_command_wrapper::tag, USB_DIR_IN, usb_stream(), and USBBLK_COMMAND_SIGNATURE.
Referenced by usbblk_start().
|
static |
Send bulk OUT data block.
usbblk | USB block device |
rc | Return status code |
Definition at line 200 of file usbblk.c.
References alloc_iob(), assert(), cmd, usbblk_device::cmd, copy_from_user(), DBGC, ENOMEM, free_iob(), usbblk_device::func, iob_put, len, usb_endpoint::mtu, usb_function::name, usbblk_device::out, rc, strerror(), UNULL, usb_stream(), and USBBLK_MAX_LEN.
Referenced by usbblk_out_refill().
|
static |
Refill bulk OUT endpoint.
usbblk | USB block device |
rc | Return status code |
Definition at line 250 of file usbblk.c.
References assert(), cmd, usbblk_device::cmd, usb_endpoint::fill, usbblk_device::out, rc, USBBLK_MAX_FILL, and usbblk_out_data().
Referenced by usbblk_step().
|
static |
Complete bulk OUT transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 274 of file usbblk.c.
References assert(), cmd, usbblk_device::cmd, container_of, DBGC, free_iob(), usbblk_device::func, usb_function::name, usb_endpoint::open, out, usbblk_device::process, process_add(), rc, strerror(), and usbblk_stop().
|
static |
Handle bulk IN data block.
usbblk | USB block device |
data | Data block |
len | Length of data |
rc | Return status code |
Definition at line 329 of file usbblk.c.
References assert(), cmd, usbblk_device::cmd, copy_to_user(), data, len, and UNULL.
Referenced by usbblk_in_complete().
|
static |
Handle bulk IN status.
usbblk | USB block device |
data | Status data |
len | Length of status data |
rc | Return status code |
Definition at line 354 of file usbblk.c.
References assert(), cmd, usbblk_device::cmd, cpu_to_le32, data, DBGC, DBGC_HDA, EIO, usbblk_device::func, le32_to_cpu, len, usb_function::name, usbblk_status_wrapper::residue, usbblk_status_wrapper::signature, usbblk_status_wrapper::status, usbblk_status_wrapper::tag, USBBLK_STATUS_SIGNATURE, and usbblk_stop().
Referenced by usbblk_in_complete().
|
static |
Refill bulk IN endpoint.
usbblk | USB block device |
rc | Return status code |
Definition at line 415 of file usbblk.c.
References assert(), cmd, usbblk_device::cmd, usbblk_device::in, max, rc, usb_refill_limit(), and USBBLK_MAX_LEN.
Referenced by usbblk_step().
|
static |
Complete bulk IN transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 447 of file usbblk.c.
References assert(), cmd, usbblk_device::cmd, container_of, io_buffer::data, DBGC, free_iob(), usbblk_device::func, in, iob_len(), iob_pull, len, usb_function::name, usb_endpoint::open, usbblk_device::process, process_add(), rc, strerror(), usbblk_in_data(), usbblk_in_status(), and usbblk_stop().
|
static |
Refill endpoints.
usbblk | USB block device |
Definition at line 523 of file usbblk.c.
References usbblk_in_refill(), and usbblk_out_refill().
|
static |
Start new SCSI command.
usbblk | USB block device |
scsicmd | SCSI command |
rc | Return status code |
Definition at line 578 of file usbblk.c.
References assert(), cmd, usbblk_device::cmd, scsi_cmd::data_in_len, scsi_cmd::data_out_len, DBGC, EBUSY, EOPNOTSUPP, usbblk_device::func, memcpy(), memset(), usb_function::name, usbblk_device::process, process_add(), process_running(), rc, usbblk_out_command(), usbblk_tag, and USBBLK_TAG_MAGIC.
Referenced by usbblk_scsi_command().
|
static |
Check SCSI command flow-control window.
usbblk | USB block device |
len | Length of window |
Definition at line 645 of file usbblk.c.
References cmd, and usbblk_device::cmd.
|
static |
Issue SCSI command.
usbblk | USB block device |
data | SCSI data interface |
scsicmd | SCSI command |
tag | Command tag, or negative error |
Definition at line 660 of file usbblk.c.
References cmd, usbblk_device::cmd, data, usbblk_device::data, usbblk_device::in, intf_plug_plug(), usb_endpoint::open, rc, usbblk_close(), usbblk_open(), usbblk_start(), and usbblk_stop().
|
static |
Close SCSI interface.
usbblk | USB block device |
rc | Reason for close |
Definition at line 691 of file usbblk.c.
References usbblk_device::data, intfs_restart(), NULL, usbblk_device::opened, rc, usbblk_device::scsi, usbblk_close(), and usbblk_stop().
Referenced by usbblk_remove().
|
static |
Describe as an EFI device path.
usbblk | USB block device |
path | EFI device path, or NULL on error |
Definition at line 713 of file usbblk.c.
References efi_usb_path(), and usbblk_device::func.
|
static |
Find USB block device.
name | USB block device name |
usbblk | USB block device, or NULL |
Definition at line 744 of file usbblk.c.
References usbblk_device::func, usbblk_device::list, list_for_each_entry, usb_function::name, name, NULL, and strcmp().
Referenced by usbblk_open_uri().
Open USB block device URI.
parent | Parent interface |
uri | URI |
rc | Return status code |
Definition at line 763 of file usbblk.c.
References DBGC, EBUSY, EINVAL, ENOENT, usbblk_device::func, lun, usb_function::name, uri::opaque, usbblk_device::opened, rc, usbblk_device::scsi, scsi_open(), strerror(), and usbblk_find().
|
static |
Probe device.
func | USB function |
config | Configuration descriptor |
rc | Return status code |
Definition at line 814 of file usbblk.c.
References usbblk_device::data, DBGC, desc, ENOENT, ENOMEM, usbblk_device::func, usbblk_device::in, usb_function::interface, intf_init(), usbblk_device::list, list_add_tail, usb_function::name, usbblk_device::out, usbblk_device::process, process_init_stopped(), rc, ref_put, usbblk_device::refcnt, usbblk_device::scsi, strerror(), usb_function::usb, USB_BULK_IN, USB_BULK_OUT, usb_endpoint_described(), usb_endpoint_init(), usb_func_set_drvdata(), usb_interface_descriptor(), usb_refill_init(), usbblk_data_desc, usbblk_in_operations, USBBLK_MAX_FILL, USBBLK_MAX_LEN, usbblk_out_operations, usbblk_process_desc, usbblk_scsi_desc, and zalloc().
|
static |
Remove device.
func | USB function |
Definition at line 878 of file usbblk.c.
References usbblk_device::data, ENODEV, usbblk_device::func, intfs_shutdown(), usbblk_device::list, list_del, NULL, ref_put, usbblk_device::refcnt, usbblk_device::scsi, usb_func_get_drvdata(), and usbblk_scsi_close().
|
static |
Bulk OUT endpoint operations.
Definition at line 310 of file usbblk.c.
Referenced by usbblk_probe().
|
static |
Bulk IN endpoint operations.
Definition at line 507 of file usbblk.c.
Referenced by usbblk_probe().
|
static |
Refill process descriptor.
Definition at line 533 of file usbblk.c.
Referenced by usbblk_probe().
|
static |
|
static |
SCSI data interface operations.
|
static |
SCSI data interface descriptor.
Definition at line 636 of file usbblk.c.
Referenced by usbblk_probe().
|
static |
SCSI command interface operations.
|
static |
SCSI command interface descriptor.
Definition at line 728 of file usbblk.c.
Referenced by usbblk_probe().
struct uri_opener usbblk_uri_opener __uri_opener |
USB block device URI opener.
|
static |
Mass storage class device IDs.
struct usb_driver usbblk_driver __usb_driver |
Mass storage driver.