]>
Commit | Line | Data |
---|---|---|
e237e7ae | 1 | /** @file\r |
3e03cb4d | 2 | Definition of USB Mass Storage Class and its value, USB Mass Transport Protocol, \r |
3 | and other common definitions.\r | |
e237e7ae | 4 | \r |
cc5166ff | 5 | Copyright (c) 2007 - 2008, Intel Corporation\r |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
e237e7ae | 10 | \r |
cc5166ff | 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
e237e7ae | 13 | \r |
14 | **/\r | |
15 | \r | |
16 | #ifndef _EFI_USBMASS_H_\r | |
17 | #define _EFI_USBMASS_H_\r | |
18 | \r | |
ed7748fe | 19 | \r |
60c93673 | 20 | #include <Uefi.h>\r |
ed7748fe | 21 | \r |
e237e7ae | 22 | #include <Protocol/BlockIo.h>\r |
23 | #include <Protocol/UsbIo.h>\r | |
c7e39923 | 24 | #include <Protocol/DevicePath.h>\r |
ed7748fe | 25 | \r |
776a705e | 26 | #include <Library/BaseLib.h>\r |
e237e7ae | 27 | #include <Library/DebugLib.h>\r |
28 | #include <Library/BaseMemoryLib.h>\r | |
29 | #include <Library/UefiDriverEntryPoint.h>\r | |
30 | #include <Library/UefiBootServicesTableLib.h>\r | |
31 | #include <Library/UefiLib.h>\r | |
32 | #include <Library/MemoryAllocationLib.h>\r | |
c7e39923 | 33 | #include <Library/DevicePathLib.h>\r |
e237e7ae | 34 | \r |
d80ed2a7 | 35 | #define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == BIT7)\r |
36 | #define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0)\r | |
37 | #define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK)\r | |
38 | #define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT)\r | |
e237e7ae | 39 | #define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)\r |
40 | \r | |
cc5166ff | 41 | typedef enum {\r |
e237e7ae | 42 | //\r |
43 | // Usb mass storage class code\r | |
44 | //\r | |
45 | USB_MASS_STORE_CLASS = 0x08,\r | |
46 | \r | |
47 | //\r | |
48 | // Usb mass storage subclass code, specify the command set used.\r | |
49 | //\r | |
d80ed2a7 | 50 | USB_MASS_STORE_RBC = 0x01, ///< Reduced Block Commands\r |
51 | USB_MASS_STORE_8020I = 0x02, ///< SFF-8020i, typically a CD/DVD device\r | |
52 | USB_MASS_STORE_QIC = 0x03, ///< Typically a tape device\r | |
53 | USB_MASS_STORE_UFI = 0x04, ///< Typically a floppy disk driver device\r | |
54 | USB_MASS_STORE_8070I = 0x05, ///< SFF-8070i, typically a floppy disk driver device.\r | |
55 | USB_MASS_STORE_SCSI = 0x06, ///< SCSI transparent command set\r | |
e237e7ae | 56 | \r |
57 | //\r | |
58 | // Usb mass storage protocol code, specify the transport protocol\r | |
59 | //\r | |
d80ed2a7 | 60 | USB_MASS_STORE_CBI0 = 0x00, ///< CBI protocol with command completion interrupt\r |
61 | USB_MASS_STORE_CBI1 = 0x01, ///< CBI protocol without command completion interrupt\r | |
62 | USB_MASS_STORE_BOT = 0x50, ///< Bulk-Only Transport\r | |
e237e7ae | 63 | \r |
41e8ff27 | 64 | USB_MASS_1_MILLISECOND = 1000,\r |
65 | USB_MASS_1_SECOND = 1000 * USB_MASS_1_MILLISECOND,\r | |
e237e7ae | 66 | \r |
67 | USB_MASS_CMD_SUCCESS = 0,\r | |
68 | USB_MASS_CMD_FAIL,\r | |
c52fa98c | 69 | USB_MASS_CMD_PERSISTENT\r |
3e03cb4d | 70 | } USB_MASS_DEV_CLASS_AND_VALUE;\r |
71 | \r | |
72 | /**\r | |
73 | Initializes USB transport protocol.\r | |
74 | \r | |
75 | This function initializes the USB mass storage class transport protocol.\r | |
76 | It will save its context in the Context if Context isn't NULL.\r | |
77 | \r | |
78 | @param UsbIo The USB I/O Protocol instance\r | |
79 | @param Context The buffer to save the context to\r | |
e237e7ae | 80 | \r |
3e03cb4d | 81 | @retval EFI_SUCCESS The device is successfully initialized.\r |
82 | @retval EFI_UNSUPPORTED The transport protocol doesn't support the device.\r | |
83 | @retval Other The USB transport initialization fails.\r | |
84 | \r | |
85 | **/\r | |
e237e7ae | 86 | typedef\r |
87 | EFI_STATUS\r | |
88 | (*USB_MASS_INIT_TRANSPORT) (\r | |
89 | IN EFI_USB_IO_PROTOCOL *Usb,\r | |
e237e7ae | 90 | OUT VOID **Context OPTIONAL\r |
91 | );\r | |
92 | \r | |
3e03cb4d | 93 | /**\r |
94 | Execute USB mass storage command through the transport protocol.\r | |
95 | \r | |
96 | @param Context The USB Transport Protocol.\r | |
97 | @param Cmd The command to transfer to device\r | |
98 | @param CmdLen The length of the command\r | |
99 | @param DataDir The direction of data transfer\r | |
100 | @param Data The buffer to hold the data\r | |
101 | @param DataLen The length of the buffer\r | |
102 | @param Lun Should be 0, this field for bot only\r | |
103 | @param Timeout The time to wait\r | |
104 | @param CmdStatus The result of the command execution\r | |
105 | \r | |
106 | @retval EFI_SUCCESS The command is executed successfully.\r | |
107 | @retval Other Failed to execute the command\r | |
108 | \r | |
109 | **/\r | |
e237e7ae | 110 | typedef\r |
111 | EFI_STATUS\r | |
112 | (*USB_MASS_EXEC_COMMAND) (\r | |
113 | IN VOID *Context,\r | |
114 | IN VOID *Cmd,\r | |
115 | IN UINT8 CmdLen,\r | |
116 | IN EFI_USB_DATA_DIRECTION DataDir,\r | |
117 | IN VOID *Data,\r | |
118 | IN UINT32 DataLen,\r | |
c7e39923 | 119 | IN UINT8 Lun,\r |
e237e7ae | 120 | IN UINT32 Timeout,\r |
121 | OUT UINT32 *CmdStatus\r | |
122 | );\r | |
123 | \r | |
3e03cb4d | 124 | /**\r |
125 | Reset the USB mass storage device by Transport protocol.\r | |
126 | \r | |
127 | @param Context The USB Transport Protocol\r | |
128 | @param ExtendedVerification The flag controlling the rule of reset.\r | |
129 | Not used here.\r | |
130 | \r | |
131 | @retval EFI_SUCCESS The device is reset.\r | |
132 | @retval Others Failed to reset the device.\r | |
133 | \r | |
134 | **/\r | |
e237e7ae | 135 | typedef\r |
136 | EFI_STATUS\r | |
137 | (*USB_MASS_RESET) (\r | |
138 | IN VOID *Context,\r | |
139 | IN BOOLEAN ExtendedVerification\r | |
140 | );\r | |
141 | \r | |
3e03cb4d | 142 | /**\r |
143 | Get the max LUN (Logical Unit Number) of USB mass storage device.\r | |
144 | \r | |
145 | @param Context The context of the transport protocol.\r | |
146 | @param MaxLun Return pointer to the max number of LUN. (e.g. MaxLun=1 means LUN0 and\r | |
147 | LUN1 in all.)\r | |
148 | \r | |
149 | @retval EFI_SUCCESS Max LUN is got successfully.\r | |
150 | @retval Others Fail to execute this request.\r | |
151 | \r | |
152 | **/\r | |
c7e39923 | 153 | typedef\r |
154 | EFI_STATUS\r | |
155 | (*USB_MASS_GET_MAX_LUN) (\r | |
156 | IN VOID *Context,\r | |
157 | IN UINT8 *MaxLun\r | |
158 | );\r | |
159 | \r | |
3e03cb4d | 160 | /**\r |
161 | Clean up the transport protocol's resource.\r | |
162 | \r | |
163 | @param Context The instance of transport protocol.\r | |
164 | \r | |
165 | @retval EFI_SUCCESS The resource is cleaned up.\r | |
166 | \r | |
167 | **/\r | |
e237e7ae | 168 | typedef\r |
169 | EFI_STATUS\r | |
d80ed2a7 | 170 | (*USB_MASS_CLEAN_UP) (\r |
e237e7ae | 171 | IN VOID *Context\r |
172 | );\r | |
173 | \r | |
d80ed2a7 | 174 | ///\r |
175 | /// This structure contains information necessary to select the\r | |
176 | /// proper transport protocol. The mass storage class defines\r | |
177 | /// two transport protocols. One is the CBI, and the other is BOT.\r | |
178 | /// CBI is being obseleted. The design is made modular by this\r | |
179 | /// structure so that the CBI protocol can be easily removed when\r | |
180 | /// it is no longer necessary.\r | |
181 | ///\r | |
e237e7ae | 182 | typedef struct {\r |
183 | UINT8 Protocol;\r | |
d80ed2a7 | 184 | USB_MASS_INIT_TRANSPORT Init; ///< Initialize the mass storage transport protocol\r |
185 | USB_MASS_EXEC_COMMAND ExecCommand; ///< Transport command to the device then get result\r | |
186 | USB_MASS_RESET Reset; ///< Reset the device\r | |
187 | USB_MASS_GET_MAX_LUN GetMaxLun; ///< Get max lun, only for bot\r | |
188 | USB_MASS_CLEAN_UP CleanUp; ///< Clean up the resources.\r | |
e237e7ae | 189 | } USB_MASS_TRANSPORT;\r |
190 | \r | |
3e03cb4d | 191 | typedef struct {\r |
192 | UINT32 Signature;\r | |
193 | EFI_HANDLE Controller;\r | |
194 | EFI_USB_IO_PROTOCOL *UsbIo;\r | |
195 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
196 | EFI_BLOCK_IO_PROTOCOL BlockIo;\r | |
197 | EFI_BLOCK_IO_MEDIA BlockIoMedia;\r | |
198 | BOOLEAN OpticalStorage;\r | |
199 | UINT8 Lun; ///< Logical Unit Number\r | |
200 | UINT8 Pdt; ///< Peripheral Device Type\r | |
201 | USB_MASS_TRANSPORT *Transport; ///< USB mass storage transport protocol\r | |
202 | VOID *Context; \r | |
203 | } USB_MASS_DEVICE;\r | |
e237e7ae | 204 | \r |
e237e7ae | 205 | #endif\r |