]>
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 |
07100795 | 5 | Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r |
cd5ebaa0 | 6 | This program and the accompanying materials\r |
cc5166ff | 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 |
99c1725e | 21 | #include <IndustryStandard/Scsi.h>\r |
e237e7ae | 22 | #include <Protocol/BlockIo.h>\r |
23 | #include <Protocol/UsbIo.h>\r | |
c7e39923 | 24 | #include <Protocol/DevicePath.h>\r |
39840c50 | 25 | #include <Protocol/DiskInfo.h>\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 |
39840c50 | 35 | typedef struct _USB_MASS_TRANSPORT USB_MASS_TRANSPORT;\r |
36 | typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;\r | |
37 | \r | |
38 | #include "UsbMassBot.h"\r | |
39 | #include "UsbMassCbi.h"\r | |
40 | #include "UsbMassBoot.h"\r | |
41 | #include "UsbMassDiskInfo.h"\r | |
42 | #include "UsbMassImpl.h"\r | |
43 | \r | |
d80ed2a7 | 44 | #define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == BIT7)\r |
45 | #define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0)\r | |
46 | #define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK)\r | |
47 | #define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT)\r | |
e237e7ae | 48 | #define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)\r |
49 | \r | |
1ccdbf2a | 50 | #define USB_MASS_1_MILLISECOND 1000\r |
51 | #define USB_MASS_1_SECOND (1000 * USB_MASS_1_MILLISECOND)\r | |
52 | \r | |
53 | #define USB_MASS_CMD_SUCCESS 0\r | |
54 | #define USB_MASS_CMD_FAIL 1\r | |
55 | #define USB_MASS_CMD_PERSISTENT 2\r | |
3e03cb4d | 56 | \r |
57 | /**\r | |
58 | Initializes USB transport protocol.\r | |
59 | \r | |
60 | This function initializes the USB mass storage class transport protocol.\r | |
61 | It will save its context in the Context if Context isn't NULL.\r | |
62 | \r | |
63 | @param UsbIo The USB I/O Protocol instance\r | |
64 | @param Context The buffer to save the context to\r | |
e237e7ae | 65 | \r |
3e03cb4d | 66 | @retval EFI_SUCCESS The device is successfully initialized.\r |
67 | @retval EFI_UNSUPPORTED The transport protocol doesn't support the device.\r | |
68 | @retval Other The USB transport initialization fails.\r | |
69 | \r | |
70 | **/\r | |
e237e7ae | 71 | typedef\r |
72 | EFI_STATUS\r | |
73 | (*USB_MASS_INIT_TRANSPORT) (\r | |
74 | IN EFI_USB_IO_PROTOCOL *Usb,\r | |
e237e7ae | 75 | OUT VOID **Context OPTIONAL\r |
76 | );\r | |
77 | \r | |
3e03cb4d | 78 | /**\r |
79 | Execute USB mass storage command through the transport protocol.\r | |
80 | \r | |
81 | @param Context The USB Transport Protocol.\r | |
82 | @param Cmd The command to transfer to device\r | |
83 | @param CmdLen The length of the command\r | |
84 | @param DataDir The direction of data transfer\r | |
85 | @param Data The buffer to hold the data\r | |
86 | @param DataLen The length of the buffer\r | |
87 | @param Lun Should be 0, this field for bot only\r | |
88 | @param Timeout The time to wait\r | |
89 | @param CmdStatus The result of the command execution\r | |
90 | \r | |
91 | @retval EFI_SUCCESS The command is executed successfully.\r | |
92 | @retval Other Failed to execute the command\r | |
93 | \r | |
94 | **/\r | |
e237e7ae | 95 | typedef\r |
96 | EFI_STATUS\r | |
97 | (*USB_MASS_EXEC_COMMAND) (\r | |
98 | IN VOID *Context,\r | |
99 | IN VOID *Cmd,\r | |
100 | IN UINT8 CmdLen,\r | |
101 | IN EFI_USB_DATA_DIRECTION DataDir,\r | |
102 | IN VOID *Data,\r | |
103 | IN UINT32 DataLen,\r | |
c7e39923 | 104 | IN UINT8 Lun,\r |
e237e7ae | 105 | IN UINT32 Timeout,\r |
106 | OUT UINT32 *CmdStatus\r | |
107 | );\r | |
108 | \r | |
3e03cb4d | 109 | /**\r |
110 | Reset the USB mass storage device by Transport protocol.\r | |
111 | \r | |
112 | @param Context The USB Transport Protocol\r | |
113 | @param ExtendedVerification The flag controlling the rule of reset.\r | |
114 | Not used here.\r | |
115 | \r | |
116 | @retval EFI_SUCCESS The device is reset.\r | |
117 | @retval Others Failed to reset the device.\r | |
118 | \r | |
119 | **/\r | |
e237e7ae | 120 | typedef\r |
121 | EFI_STATUS\r | |
122 | (*USB_MASS_RESET) (\r | |
123 | IN VOID *Context,\r | |
124 | IN BOOLEAN ExtendedVerification\r | |
125 | );\r | |
126 | \r | |
3e03cb4d | 127 | /**\r |
128 | Get the max LUN (Logical Unit Number) of USB mass storage device.\r | |
129 | \r | |
130 | @param Context The context of the transport protocol.\r | |
131 | @param MaxLun Return pointer to the max number of LUN. (e.g. MaxLun=1 means LUN0 and\r | |
132 | LUN1 in all.)\r | |
133 | \r | |
134 | @retval EFI_SUCCESS Max LUN is got successfully.\r | |
135 | @retval Others Fail to execute this request.\r | |
136 | \r | |
137 | **/\r | |
c7e39923 | 138 | typedef\r |
139 | EFI_STATUS\r | |
140 | (*USB_MASS_GET_MAX_LUN) (\r | |
141 | IN VOID *Context,\r | |
142 | IN UINT8 *MaxLun\r | |
143 | );\r | |
144 | \r | |
3e03cb4d | 145 | /**\r |
146 | Clean up the transport protocol's resource.\r | |
147 | \r | |
148 | @param Context The instance of transport protocol.\r | |
149 | \r | |
150 | @retval EFI_SUCCESS The resource is cleaned up.\r | |
151 | \r | |
152 | **/\r | |
e237e7ae | 153 | typedef\r |
154 | EFI_STATUS\r | |
d80ed2a7 | 155 | (*USB_MASS_CLEAN_UP) (\r |
e237e7ae | 156 | IN VOID *Context\r |
157 | );\r | |
158 | \r | |
d80ed2a7 | 159 | ///\r |
160 | /// This structure contains information necessary to select the\r | |
161 | /// proper transport protocol. The mass storage class defines\r | |
162 | /// two transport protocols. One is the CBI, and the other is BOT.\r | |
163 | /// CBI is being obseleted. The design is made modular by this\r | |
164 | /// structure so that the CBI protocol can be easily removed when\r | |
165 | /// it is no longer necessary.\r | |
166 | ///\r | |
39840c50 | 167 | struct _USB_MASS_TRANSPORT {\r |
e237e7ae | 168 | UINT8 Protocol;\r |
d80ed2a7 | 169 | USB_MASS_INIT_TRANSPORT Init; ///< Initialize the mass storage transport protocol\r |
170 | USB_MASS_EXEC_COMMAND ExecCommand; ///< Transport command to the device then get result\r | |
171 | USB_MASS_RESET Reset; ///< Reset the device\r | |
172 | USB_MASS_GET_MAX_LUN GetMaxLun; ///< Get max lun, only for bot\r | |
173 | USB_MASS_CLEAN_UP CleanUp; ///< Clean up the resources.\r | |
39840c50 | 174 | };\r |
e237e7ae | 175 | \r |
39840c50 | 176 | struct _USB_MASS_DEVICE {\r |
3e03cb4d | 177 | UINT32 Signature;\r |
178 | EFI_HANDLE Controller;\r | |
179 | EFI_USB_IO_PROTOCOL *UsbIo;\r | |
180 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
181 | EFI_BLOCK_IO_PROTOCOL BlockIo;\r | |
182 | EFI_BLOCK_IO_MEDIA BlockIoMedia;\r | |
183 | BOOLEAN OpticalStorage;\r | |
184 | UINT8 Lun; ///< Logical Unit Number\r | |
185 | UINT8 Pdt; ///< Peripheral Device Type\r | |
186 | USB_MASS_TRANSPORT *Transport; ///< USB mass storage transport protocol\r | |
39840c50 | 187 | VOID *Context;\r |
188 | EFI_DISK_INFO_PROTOCOL DiskInfo;\r | |
189 | USB_BOOT_INQUIRY_DATA InquiryData;\r | |
99c1725e | 190 | BOOLEAN Cdb16Byte;\r |
39840c50 | 191 | };\r |
e237e7ae | 192 | \r |
e237e7ae | 193 | #endif\r |