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