[acpi] Expose system MAC address via ${sysmac} setting
[ipxe.git] / src / drivers / usb / usbblk.h
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 */
31 struct usbblk_command_wrapper {
32 /** Signature */
33 uint32_t signature;
34 /** Tag */
35 uint32_t tag;
36 /** Data transfer length */
37 uint32_t len;
38 /** Flags */
39 uint8_t flags;
40 /** LUN */
41 uint8_t lun;
42 /** Command block length */
43 uint8_t cblen;
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 */
52 struct usbblk_status_wrapper {
53 /** Signature */
54 uint32_t signature;
55 /** Tag */
56 uint32_t tag;
57 /** Data residue */
58 uint32_t residue;
59 /** Status */
60 uint8_t status;
61 } __attribute__ (( packed ));
62
63 /** Command status wrapper signature */
64 #define USBBLK_STATUS_SIGNATURE 0x53425355UL
65
66 /** A USB mass storage command */
67 struct usbblk_command {
68 /** SCSI command */
69 struct scsi_cmd scsi;
70 /** Command tag (0 for no command in progress) */
71 uint32_t tag;
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) */
100 struct usbblk_command cmd;
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 */