iPXE
usbblk.h
Go to the documentation of this file.
1#ifndef _USBBLK_H
2#define _USBBLK_H
3
4/** @file
5 *
6 * USB mass storage driver
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/usb.h>
15#include <ipxe/scsi.h>
16#include <ipxe/interface.h>
17
18/** Mass storage class code */
19#define USB_CLASS_MSC 0x08
20
21/** SCSI command set subclass code */
22#define USB_SUBCLASS_MSC_SCSI 0x06
23
24/** Bulk-only transport protocol */
25#define USB_PROTOCOL_MSC_BULK 0x50
26
27/** Mass storage reset command */
28#define USBBLK_RESET ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
29 USB_REQUEST_TYPE ( 255 ) )
30
31/** Command block wrapper */
33 /** Signature */
35 /** Tag */
37 /** Data transfer length */
39 /** Flags */
41 /** LUN */
43 /** Command block length */
45 /** Command block */
47} __attribute__ (( packed ));
48
49/** Command block wrapper signature */
50#define USBBLK_COMMAND_SIGNATURE 0x43425355UL
51
52/** Command status wrapper */
54 /** Signature */
56 /** Tag */
58 /** Data residue */
60 /** Status */
62} __attribute__ (( packed ));
63
64/** Command status wrapper signature */
65#define USBBLK_STATUS_SIGNATURE 0x53425355UL
66
67/** A USB mass storage command */
69 /** SCSI command */
70 struct scsi_cmd scsi;
71 /** Command tag (0 for no command in progress) */
73 /** Offset within data buffer */
74 size_t offset;
75};
76
77/** A USB mass storage device */
79 /** Reference count */
80 struct refcnt refcnt;
81 /** List of devices */
83
84 /** USB function */
86 /** Bulk OUT endpoint */
88 /** Bulk IN endpoint */
90
91 /** SCSI command-issuing interface */
93 /** SCSI data interface */
95 /** Command process */
97 /** Device opened flag */
98 int opened;
99
100 /** Current command (if any) */
102};
103
104/** Command tag magic
105 *
106 * This is a policy decision.
107 */
108#define USBBLK_TAG_MAGIC 0x18ae0000
109
110/** Maximum length of USB data block
111 *
112 * This is a policy decision.
113 */
114#define USBBLK_MAX_LEN 2048
115
116/** Maximum endpoint fill level
117 *
118 * This is a policy decision.
119 */
120#define USBBLK_MAX_FILL 4
121
122#endif /* _USBBLK_H */
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
Universal Serial Bus (USB)
Object interfaces.
SCSI devices.
An object interface.
Definition interface.h:125
A doubly-linked list entry (or list head)
Definition list.h:19
A SCSI command information unit.
Definition scsi.h:249
A USB endpoint.
Definition usb.h:404
A USB function.
Definition usb.h:674
Command block wrapper.
Definition usbblk.h:32
uint8_t lun
LUN.
Definition usbblk.h:42
uint8_t flags
Flags.
Definition usbblk.h:40
uint8_t cblen
Command block length.
Definition usbblk.h:44
uint32_t len
Data transfer length.
Definition usbblk.h:38
uint32_t tag
Tag.
Definition usbblk.h:36
uint8_t cb[16]
Command block.
Definition usbblk.h:46
uint32_t signature
Signature.
Definition usbblk.h:34
A USB mass storage command.
Definition usbblk.h:68
size_t offset
Offset within data buffer.
Definition usbblk.h:74
struct scsi_cmd scsi
SCSI command.
Definition usbblk.h:70
uint32_t tag
Command tag (0 for no command in progress)
Definition usbblk.h:72
A USB mass storage device.
Definition usbblk.h:78
struct usb_endpoint in
Bulk IN endpoint.
Definition usbblk.h:89
struct process process
Command process.
Definition usbblk.h:96
struct usb_endpoint out
Bulk OUT endpoint.
Definition usbblk.h:87
struct refcnt refcnt
Reference count.
Definition usbblk.h:80
int opened
Device opened flag.
Definition usbblk.h:98
struct usb_function * func
USB function.
Definition usbblk.h:85
struct list_head list
List of devices.
Definition usbblk.h:82
struct usbblk_command cmd
Current command (if any)
Definition usbblk.h:101
struct interface scsi
SCSI command-issuing interface.
Definition usbblk.h:92
struct interface data
SCSI data interface.
Definition usbblk.h:94
Command status wrapper.
Definition usbblk.h:53
uint32_t residue
Data residue.
Definition usbblk.h:59
uint32_t signature
Signature.
Definition usbblk.h:55
uint32_t tag
Tag.
Definition usbblk.h:57
uint8_t status
Status.
Definition usbblk.h:61