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 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_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 */
46  uint8_t cb[16];
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 */
78 struct usbblk_device {
79  /** Reference count */
80  struct refcnt refcnt;
81  /** List of devices */
82  struct list_head list;
83 
84  /** USB function */
85  struct usb_function *func;
86  /** Bulk OUT endpoint */
87  struct usb_endpoint out;
88  /** Bulk IN endpoint */
89  struct usb_endpoint in;
90 
91  /** SCSI command-issuing interface */
92  struct interface scsi;
93  /** SCSI data interface */
94  struct interface data;
95  /** Command process */
96  struct process 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 */
A process.
Definition: process.h:18
#define __attribute__(x)
Definition: compiler.h:10
struct usb_endpoint out
Bulk OUT endpoint.
Definition: usbblk.h:87
struct usbblk_command cmd
Current command (if any)
Definition: usbblk.h:101
A USB mass storage command.
Definition: usbblk.h:68
uint8_t cb[16]
Command block.
Definition: usbblk.h:46
uint8_t cblen
Command block length.
Definition: usbblk.h:44
uint32_t tag
Command tag (0 for no command in progress)
Definition: usbblk.h:72
Command block wrapper.
Definition: usbblk.h:32
uint32_t signature
Signature.
Definition: usbblk.h:34
A doubly-linked list entry (or list head)
Definition: list.h:19
A reference counter.
Definition: refcnt.h:27
A USB endpoint.
Definition: usb.h:404
size_t offset
Offset within data buffer.
Definition: usbblk.h:74
struct interface scsi
SCSI command-issuing interface.
Definition: usbblk.h:92
An object interface.
Definition: interface.h:125
uint8_t lun
LUN.
Definition: usbblk.h:42
A USB mass storage device.
Definition: usbblk.h:78
Object interfaces.
struct list_head list
List of devices.
Definition: usbblk.h:82
unsigned char uint8_t
Definition: stdint.h:10
uint32_t residue
Data residue.
Definition: usbblk.h:59
unsigned int uint32_t
Definition: stdint.h:12
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbblk.h:89
Command status wrapper.
Definition: usbblk.h:53
struct usb_function * func
USB function.
Definition: usbblk.h:85
uint32_t tag
Tag.
Definition: usbblk.h:36
SCSI devices.
A SCSI command information unit.
Definition: scsi.h:249
uint32_t tag
Tag.
Definition: usbblk.h:57
Universal Serial Bus (USB)
uint8_t status
Status.
Definition: usbblk.h:61
int opened
Device opened flag.
Definition: usbblk.h:98
uint32_t signature
Signature.
Definition: usbblk.h:55
A USB function.
Definition: usb.h:674
struct scsi_cmd scsi
SCSI command.
Definition: usbblk.h:70
FILE_SECBOOT(PERMITTED)
uint32_t len
Data transfer length.
Definition: usbblk.h:38
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct interface data
SCSI data interface.
Definition: usbblk.h:94
uint8_t flags
Flags.
Definition: usbblk.h:40