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